Changeset 1089

Show
Ignore:
Timestamp:
09/03/06 18:54:01 (5 years ago)
Author:
max-horvath
Message:

"2006-09-03 Max Horvath <max.horvath@…>

  • The term SPLASH_ONLY_USER displayed to people visiting the portal has been replaced by the more meaningful term \"anonymous user\" (fixes #106)
  • When creating a new node and choosing an existing node_id there will be shown an error message (fixes #223)
  • If one or more nodes aren't monitored they now will be announced on the front page (instead of just showing the number of monitored online nodes) (fixes #100)
  • Display more meaningful error messages if required user permissions are missing (fixes #242)
  • Refactored Network->getAdminUI() to match look and feel of Node->getAdminUI (fixes #140)
  • Show descriptive status of node (fixes #241)"
Location:
trunk/wifidog-auth
Files:
9 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/CHANGELOG

    r1088 r1089  
     12006-09-03 Max Horváth <max.horvath@maxspot.de> 
     2        * The term SPLASH_ONLY_USER displayed to people visiting the portal has been 
     3          replaced by the more meaningful term "anonymous user" (fixes #106) 
     4        * When creating a new node and choosing an existing node_id there will be 
     5          shown an error message (fixes #223) 
     6        * If one or more nodes aren't monitored they now will be announced on the 
     7          front page (instead of just showing the number of monitored online nodes) 
     8          (fixes #100) 
     9        * Display more meaningful error messages if required user permissions are 
     10          missing (fixes #242) 
     11        * Refactored Network->getAdminUI() to match look and feel of 
     12          Node->getAdminUI (fixes #140) 
     13        * Show descriptive status of node (fixes #241) 
     14 
    1152006-09-02 Max Horváth <max.horvath@maxspot.de> 
    216        * Installation script checks for PHP session extension (fixes #139) 
  • trunk/wifidog-auth/wifidog/admin/generic_object_admin.php

    r1070 r1089  
    6868require_once('classes/InterfaceElements.php'); 
    6969 
     70// Check user permissions 
     71try { 
     72    $user = User::getCurrentUser(); 
     73 
     74    if (!isset($user)) { 
     75        throw new Exception(_('Access denied!')); 
     76    } else if ((!$user->isSuperAdmin() && !$user->isOwner()) || $user->isNobody()) { 
     77        throw new Exception(_('Access denied!')); 
     78    } 
     79} catch (Exception $e) { 
     80    $ui = new MainUI(); 
     81    $ui->setToolSection('ADMIN'); 
     82    $ui->displayError($e->getMessage(), false); 
     83    exit; 
     84} 
     85 
    7086// Init values 
    7187$html = ""; 
  • trunk/wifidog-auth/wifidog/classes/Content.php

    r1086 r1089  
    5151require_once ('classes/Cache.php'); 
    5252require_once ('classes/HyperLink.php'); 
     53require_once ('classes/MainUI.php'); 
     54 
    5355/** 
    5456 * Defines any type of content 
     
    104106     */ 
    105107    private $is_logging_enabled; 
    106      
     108 
    107109    /** Log as part of this other content */ 
    108110    private $log_as_content; 
     
    712714     * @access public 
    713715     */ 
    714     public static function getSelectExistingContentUI($user_prefix, $sql_additional_where = null, $show_persistant_content = true, $order = "creation_timestamp", $type_interface = "select") { 
    715             // Define globals 
    716     global $db; 
     716    public static function getSelectExistingContentUI($user_prefix, $sql_additional_where = null, $show_persistant_content = true, $order = "creation_timestamp", $type_interface = "select") 
     717    { 
     718        // Define globals 
     719        global $db; 
    717720 
    718721        // Init values 
     
    721724        $contentRows = null; 
    722725 
    723         if (!User :: getCurrentUser()) { 
    724             throw new Exception(_('Access denied!')); 
     726        try { 
     727            if (!User :: getCurrentUser()) { 
     728                throw new Exception(_('Access denied!')); 
     729            } 
     730        } catch (Exception $e) { 
     731            $ui = new MainUI(); 
     732            $ui->setToolSection('ADMIN'); 
     733            $ui->displayError($e->getMessage(), false); 
     734            exit; 
    725735        } 
    726736 
    727737        if ($type_interface != "table") { 
    728                     $html .= "<fieldset class='admin_container Content'>\n"; 
    729         if(!empty($title)){ 
    730                 $html .= "<legend>$title</legend>\n"; 
    731                 } 
     738            $html .= "<fieldset class='admin_container Content'>\n"; 
     739 
     740            if (!empty($title)) { 
     741                $html .= "<legend>$title</legend>\n"; 
     742            } 
     743 
    732744            $html .= _("Add existing content").": "; 
    733745        } 
     
    752764 
    753765            foreach ($contentRows as $contentRow) { 
    754                 $content = Content :: getObject($contentRow['content_id']); 
    755  
    756                 if (User :: getCurrentUser()->isSuperAdmin() || $content->isOwner(User :: getCurrentUser())) { 
     766                $content = Content::getObject($contentRow['content_id']); 
     767 
     768                if (User::getCurrentUser()->isSuperAdmin() || $content->isOwner(User::getCurrentUser())) { 
    757769                    if ($type_interface != "table") { 
    758770                        $tab[$i][0] = $content->getId(); 
     
    10881100 
    10891101 
    1090 /** Allow logging as part of another content (usually the parent for metadata).   
     1102/** Allow logging as part of another content (usually the parent for metadata). 
    10911103 * Redirects clickthrough logging to the parent's content id, and does not log 
    10921104 * display */ 
     
    11801192                $this->titleShouldDisplay() ? $checked = 'CHECKED' : $checked = ''; 
    11811193                $html_title_is_displayed .= "<input type='checkbox' name='$name' $checked>\n"; 
    1182                  
     1194 
    11831195                /* title */ 
    11841196                $html .= "<li class='admin_element_item_container admin_section_edit_title'>\n"; 
    1185                 $html .= "<div class='admin_element_data'>\n";   
     1197                $html .= "<div class='admin_element_data'>\n"; 
    11861198                if (empty ($this->content_row['title'])) { 
    1187                     $html .= self :: getNewContentUI("title_{$this->id}_new", null, _("Title:"));                 
     1199                    $html .= self :: getNewContentUI("title_{$this->id}_new", null, _("Title:")); 
    11881200                    $html .= "</div>\n"; 
    11891201                } else { 
    1190                     $html .= $html_title_is_displayed;  
     1202                    $html .= $html_title_is_displayed; 
    11911203                    $title = self :: getObject($this->content_row['title']); 
    11921204                    $html .= $title->getAdminUI(null, _("Title:")); 
     
    11991211                $html .= "</li>\n"; 
    12001212            } 
    1201              
     1213 
    12021214            if ($this->is_trivial_content == false) { 
    12031215                /* description */ 
     
    12521264                $html .= "</li>\n"; 
    12531265            } 
    1254              
     1266 
    12551267            //End content medatada 
    12561268                        if ($this->is_trivial_content == false || $this->isPersistent()) { 
    12571269                        $html .= "</fieldset>\n"; 
    12581270                        } 
    1259             if ($this->is_trivial_content == false || $this->isPersistent()) {                   
     1271            if ($this->is_trivial_content == false || $this->isPersistent()) { 
    12601272                $html .= "<fieldset class='admin_element_group'>\n"; 
    12611273                                $html .= "<legend>".sprintf(_("%s access control"),get_class($this))."</legend>\n"; 
     
    13301342            {//Content medatada 
    13311343 
    1332                  
     1344 
    13331345                            if ($this->is_trivial_content == false || $this->isPersistent()) { 
    13341346                                            /* title_is_displayed */ 
     
    15151527        return $retval; 
    15161528    } 
    1517      
     1529 
    15181530    /** Set if the content group is persistent 
    15191531     * @param $is_locative_content true or false 
  • trunk/wifidog-auth/wifidog/classes/Network.php

    r1085 r1089  
    11<?php 
    2  
    32 
    43/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 
     
    4847 * Load required classes 
    4948 */ 
    50 require_once ('classes/GenericObject.php'); 
    51 require_once ('classes/Content.php'); 
    52 require_once ('classes/User.php'); 
    53 require_once ('classes/Node.php'); 
    54 require_once ('classes/GisPoint.php'); 
    55 require_once ('classes/Cache.php'); 
    56 require_once ('classes/ThemePack.php'); 
     49require_once('classes/GenericObject.php'); 
     50require_once('classes/Content.php'); 
     51require_once('classes/User.php'); 
     52require_once('classes/Node.php'); 
     53require_once('classes/GisPoint.php'); 
     54require_once('classes/Cache.php'); 
     55require_once('classes/ThemePack.php'); 
     56require_once('classes/InterfaceElements.php'); 
     57require_once('classes/MainUI.php'); 
    5758 
    5859/** 
     
    6768 * @copyright  2006 Max Horvath, maxspot GmbH 
    6869 */ 
    69 class Network implements GenericObject { 
    70     private $id; /**< The network id */ 
     70class Network implements GenericObject 
     71{ 
     72    /** 
     73     * The network Id 
     74     * 
     75     * @var string 
     76     * 
     77     * @access private 
     78     */ 
     79    private $id; 
     80 
    7181    private $mRow; 
    7282 
    73     /** Get an instance of the object 
    74     * @see GenericObject 
    75     * @param $id The object id 
    76     * @return the Content object, or null if there was an error (an exception is also thrown) 
    77     */ 
    78     static public function getObject($id) { 
     83    /** 
     84     * Get an instance of the object 
     85     * 
     86     * @param string $id The object id 
     87     * 
     88     * @return mixed The Content object, or null if there was an error 
     89     *               (an exception is also thrown) 
     90     * 
     91     * @see GenericObject 
     92     * @static 
     93     * @access public 
     94     */ 
     95    public static function getObject($id) 
     96    { 
    7997        return new self($id); 
    8098    } 
    8199 
    82     /** Get all the Networks configured on this server 
    83      * @return an array of Network objects.  The default network is returned 
    84      * first 
    85      */ 
    86     static function getAllNetworks() { 
     100    /** 
     101     * Get all the Networks configured on this server 
     102     * 
     103     * @return array An array of Network objects.  The default network is 
     104     *               returned first 
     105     * 
     106     * @static 
     107     * @access public 
     108     */ 
     109    public static function getAllNetworks() 
     110    { 
    87111        $retval = array (); 
    88112        global $db; 
     
    99123    } 
    100124 
    101     /** Get the default network 
    102      * @return a Network object, NEVER returns null. 
    103      */ 
    104     static function getDefaultNetwork($real_network_only = false) { 
     125    /** 
     126     * Get the default network 
     127     * 
     128     * @param bool $real_network_only Return a real network only? 
     129     * 
     130     * @return object A Network object, NEVER returns null. 
     131     * 
     132     * @static 
     133     * @access public 
     134     */ 
     135    public static function getDefaultNetwork($real_network_only = false) 
     136    { 
    105137        $retval = null; 
    106138        global $db; 
     
    115147    } 
    116148 
    117     /** Get the current network for which the portal is displayed or to which a user is physically connected. 
    118      * @param $real_network_only NOT IMPLEMENTED YET true or false.  If true, 
    119      * the real physical network where the user is connected is returned, and 
    120      * the node set by setCurrentNode is ignored. 
    121      * @return a Network object, NEVER returns null. 
    122      */ 
    123     static function getCurrentNetwork($real_network_only = false) { 
     149    /** 
     150     * Get the current network for which the portal is displayed or to which a 
     151     * user is physically connected. 
     152     * 
     153     * @param bool $real_network_only NOT IMPLEMENTED YET true or false.  If 
     154     *                                true, the real physical network where the 
     155     *                                user is connected is returned, and 
     156     *                                the node set by setCurrentNode is ignored. 
     157     * 
     158     * @return objetc A Network object, NEVER returns null. 
     159     * 
     160     * @static 
     161     * @access public 
     162     */ 
     163    public static function getCurrentNetwork($real_network_only = false) 
     164    { 
    124165        $retval = null; 
    125166        $current_node = Node :: getCurrentNode(); 
     167 
    126168        if ($current_node != null) { 
    127169            $retval = $current_node->getNetwork(); 
    128         } 
    129         else { 
     170        } else { 
    130171            $retval = Network :: getDefaultNetwork(); 
    131172        } 
     173 
    132174        return $retval; 
    133175    } 
    134176 
    135     /** Create a new Content object in the database 
     177    /** 
     178     * Create a new Content object in the database 
     179     * 
     180     * @param string $network_id The network id of the new network.  If absent, 
     181     *                           will be assigned a guid. 
     182     * 
     183     * @return mixed The newly created object, or null if there was an error 
     184     * 
    136185     * @see GenericObject 
    137      * @param $network_id The network id of the new network.  If absent, will be 
    138      * assigned a guid. 
    139      * @return the newly created object, or null if there was an error 
    140      */ 
    141     static function createNewObject($network_id = null) { 
     186     * @static 
     187     * @access public 
     188     */ 
     189    public static function createNewObject($network_id = null) 
     190    { 
    142191        global $db; 
    143192        if (empty ($network_id)) { 
     
    174223     * @access public 
    175224     */ 
    176     public static function getSelectNetworkUI($user_prefix, $pre_selected_network = null, $additional_where = null) { 
     225    public static function getSelectNetworkUI($user_prefix, $pre_selected_network = null, $additional_where = null) 
     226    { 
    177227        $html = ''; 
    178228        $name = $user_prefix; 
     
    180230        if ($pre_selected_network) { 
    181231            $selected_id = $pre_selected_network->getId(); 
    182         } 
    183         else { 
     232        } else { 
    184233            $selected_id = null; 
    185234        } 
     235 
    186236        global $db; 
    187237        $additional_where = $db->escapeString($additional_where); 
     
    204254            $html .= FormSelectGenerator :: generateFromArray($tab, $selected_id, $name, null, false); 
    205255 
    206         } 
    207         else { 
     256        } else { 
    208257            foreach ($network_rows as $network_row) //iterates only once... 
    209258                { 
     
    228277     * @access public 
    229278     */ 
    230     public static function processSelectNetworkUI($user_prefix) { 
     279    public static function processSelectNetworkUI($user_prefix) 
     280    { 
    231281        $name = "{$user_prefix}"; 
    232         if (!empty ($_REQUEST[$name])) 
     282 
     283        if (!empty ($_REQUEST[$name])) { 
    233284            return new self($_REQUEST[$name]); 
    234         else 
     285        } else { 
    235286            throw new exception(sprintf(_("Unable to retrieve the selected network, the %s REQUEST parameter does not exist"), $name)); 
    236     } 
    237  
    238     /** Get an interface to create a new network. 
    239     * @return html markup 
    240     */ 
    241     public static function getCreateNewObjectUI() { 
     287        } 
     288    } 
     289 
     290    /** 
     291     * Get an interface to create a new network. 
     292     * 
     293     * @return string HTML markup 
     294     * 
     295     * @static 
     296     * @access public 
     297     */ 
     298    public static function getCreateNewObjectUI() 
     299    { 
     300        // Init values 
    242301        $html = ''; 
     302 
    243303        $html .= _("Create a new network with ID")." \n"; 
    244304        $name = "new_network_id"; 
    245305        $html .= "<input type='text' size='10' name='{$name}'>\n"; 
     306 
    246307        return $html; 
    247  
    248     } 
    249  
    250     /** Process the new object interface. 
    251      *  Will return the new object if the user has the credentials and the form was fully filled. 
    252      * @return the Network object or null if no new Network was created. 
    253      */ 
    254     static function processCreateNewObjectUI() { 
     308    } 
     309 
     310    /** 
     311     * Process the new object interface. 
     312     * 
     313     * Will return the new object if the user has the credentials and the form 
     314     * was fully filled. 
     315     * 
     316     * @return mixed The Network object or null if no new Network was created. 
     317     * 
     318     * @static 
     319     * @access public 
     320     */ 
     321    public static function processCreateNewObjectUI() 
     322    { 
     323        // Init values 
    255324        $retval = null; 
    256325        $name = "new_network_id"; 
    257         if (!empty ($_REQUEST[$name])) { 
     326 
     327        if (!empty($_REQUEST[$name])) { 
    258328            $network_id = $_REQUEST[$name]; 
     329 
    259330            if ($network_id) { 
    260                 if (!User :: getCurrentUser()->isSuperAdmin()) { 
    261                     throw new Exception(_("Access denied")); 
     331                try { 
     332                    if (!User::getCurrentUser()->isSuperAdmin()) { 
     333                        throw new Exception(_("Access denied")); 
     334                    } 
     335                } catch (Exception $e) { 
     336                    $ui = new MainUI(); 
     337                    $ui->setToolSection('ADMIN'); 
     338                    $ui->displayError($e->getMessage(), false); 
     339                    exit; 
    262340                } 
    263                 $retval = self :: createNewObject($network_id); 
    264             } 
    265         } 
     341 
     342                $retval = self::createNewObject($network_id); 
     343            } 
     344        } 
     345 
    266346        return $retval; 
    267347    } 
    268348 
    269     private function __construct($p_network_id) { 
     349    /** 
     350     * Constructor 
     351     * 
     352     * @param string $p_network_id 
     353     * 
     354     * @return void 
     355     * 
     356     * @access private 
     357     */ 
     358    private function __construct($p_network_id) 
     359    { 
     360        // Define globals 
    270361        global $db; 
    271362 
     
    281372    } 
    282373 
    283     /** Retreives the id of the object 
    284      * @return The id */ 
    285     public function getId() { 
     374    /** 
     375     * Retreives the id of the object 
     376     * 
     377     * @return string The id 
     378     * 
     379     * @access public 
     380     */ 
     381    public function getId() 
     382    { 
    286383        return $this->id; 
    287384    } 
    288385 
    289     /** Retreives the network name 
    290      * @return The id */ 
    291     public function getTechSupportEmail() { 
     386    /** 
     387     * Retreives the network name 
     388     * 
     389     * @return string The id 
     390     * 
     391     * @access public 
     392     */ 
     393    public function getTechSupportEmail() 
     394    { 
    292395        return $this->mRow['tech_support_email']; 
    293396    } 
    294397 
    295     /** Set the network's tech support and information email address 
    296      * @param $value The new value 
    297      * @return true on success, false on failure */ 
    298     function setTechSupportEmail($value) { 
     398    /** 
     399     * Set the network's tech support and information email address 
     400     * 
     401     * @param string $value The new value 
     402     * 
     403     * @return bool True on success, false on failure 
     404     * 
     405     * @access public 
     406     */ 
     407    public function setTechSupportEmail($value) 
     408    { 
     409        // Init values 
    299410        $retval = true; 
     411 
    300412        if ($value != $this->getName()) { 
    301413            global $db; 
     
    304416            $this->refresh(); 
    305417        } 
     418 
    306419        return $retval; 
    307420    } 
     
    309422    /** 
    310423     * Retrieves the network name 
    311      * @return A string 
    312      */ 
    313     public function getName() { 
     424     * 
     425     * @return string A string 
     426     * 
     427     * @access public 
     428     */ 
     429    public function getName() 
     430    { 
    314431        return $this->mRow['name']; 
    315432    } 
    316433 
    317     /** Set the network's name 
    318      * @param $value The new value 
    319      * @return true on success, false on failure 
    320      */ 
    321     function setName($value) { 
     434    /** 
     435     * Set the network's name 
     436     * 
     437     * @param string $value The new value 
     438     * 
     439     * @return bool True on success, false on failure 
     440     * 
     441     * @access public 
     442     */ 
     443    public function setName($value) 
     444    { 
     445        // Init values 
    322446        $retval = true; 
     447 
    323448        if ($value != $this->getName()) { 
    324449            global $db; 
     
    327452            $this->refresh(); 
    328453        } 
     454 
    329455        return $retval; 
    330456    } 
     
    332458    /** 
    333459     * Retrieves the network's theme pack 
    334      * @return ThemePack or null 
    335      */ 
    336     public function getThemePack() { 
     460     * 
     461     * @return mixed ThemePack or null 
     462     * 
     463     * @access public 
     464     */ 
     465    public function getThemePack() 
     466    { 
    337467        if (!empty ($this->mRow['theme_pack'])) { 
    338468            return ThemePack::getObject($this->mRow['theme_pack']); 
    339         } 
    340         else { 
     469        } else { 
    341470            return null; 
    342471        } 
    343472    } 
    344473 
    345     /** Set the network's name 
    346      * @param $value The new ThemePack, or null 
    347      * @return true on success, false on failure 
    348      */ 
    349     function setThemePack($value) { 
     474    /** 
     475     * Set the network's name 
     476     * 
     477     * @param string $value The new ThemePack, or null 
     478     * 
     479     * @return bool True on success, false on failure 
     480     * 
     481     * @access public 
     482     */ 
     483    public function setThemePack($value) 
     484    { 
     485        // Init values 
    350486        $retval = true; 
     487 
    351488        if ($value != $this->getThemePack()) { 
    352489            global $db; 
     
    355492            $this->refresh(); 
    356493        } 
     494 
    357495        return $retval; 
    358496    } 
     497 
    359498    /** 
    360499     * Retrieves the network's creation date 
    361500     * 
    362501     * @return string Network's creation date 
    363      */ 
    364     public function getCreationDate() { 
     502     * 
     503     * @access public 
     504     */ 
     505    public function getCreationDate() 
     506    { 
    365507        return $this->mRow['creation_date']; 
    366508    } 
     
    375517     * @access public 
    376518     */ 
    377     public function setCreationDate($value) { 
     519    public function setCreationDate($value) 
     520    { 
    378521        // Define globals 
    379522        global $db; 
     
    391534    } 
    392535 
    393     /** Retreives the network's homepage url 
    394      * @return The id */ 
    395     public function getHomepageURL() { 
     536    /** 
     537     * Retreives the network's homepage url 
     538     * 
     539     * @return string The id 
     540     * 
     541     * @access public 
     542     */ 
     543    public function getHomepageURL() 
     544    { 
    396545        return $this->mRow['homepage_url']; 
    397546    } 
    398547 
    399     /** Set the network's homepage url 
    400      * @param $value The new value 
    401      * @return true on success, false on failure */ 
    402     function setHomepageURL($value) { 
     548    /** 
     549     * Set the network's homepage url 
     550     * 
     551     * @param string $value The new value 
     552     * 
     553     * @return bool True on success, false on failure 
     554     * 
     555     * @access public 
     556     */ 
     557    public function setHomepageURL($value) 
     558    { 
     559        // Init values 
    403560        $retval = true; 
     561 
    404562        if ($value != $this->getName()) { 
    405563            global $db; 
     
    408566            $this->refresh(); 
    409567        } 
     568 
    410569        return $retval; 
    411570    } 
     
    418577     * @access public 
    419578     */ 
    420     public function getAuthenticatorClassName() { 
     579    public function getAuthenticatorClassName() 
     580    { 
    421581        return $this->mRow['network_authenticator_class']; 
    422582    } 
     
    434594     * @access public 
    435595     */ 
    436     public function setAuthenticatorClassName($value) { 
     596    public function setAuthenticatorClassName($value) 
     597    { 
    437598        // Define globals 
    438599        global $db; 
     
    457618     * @access public 
    458619     */ 
    459     public function getAuthenticatorConstructorParams() { 
     620    public function getAuthenticatorConstructorParams() 
     621    { 
    460622        return $this->mRow['network_authenticator_params']; 
    461623    } 
     
    472634     * @access public 
    473635     */ 
    474     public function setAuthenticatorConstructorParams($value) { 
     636    public function setAuthenticatorConstructorParams($value) 
     637    { 
    475638        // Define globals 
    476639        global $db; 
     
    495658     * @access public 
    496659     */ 
    497     public function getAuthenticator() { 
     660    public function getAuthenticator() 
     661    { 
    498662        require_once ('classes/Authenticator.php'); 
    499663 
     
    516680     * @access public 
    517681     */ 
    518     public static function getAvailableAuthenticators() { 
     682    public static function getAvailableAuthenticators() 
     683    { 
    519684        // Init values 
    520685        $_authenticators = array (); 
     
    589754     * @access public 
    590755     */ 
    591     public static function getSelectAuthenticator($user_prefix, $pre_selected_authenticator = null) { 
    592             // Define globals 
    593     global $db; 
     756    public static function getSelectAuthenticator($user_prefix, $pre_selected_authenticator = null) 
     757    { 
     758        // Define globals 
     759        global $db; 
    594760 
    595761        // Init values 
     
    617783     * Is the network the default network? 
    618784     * 
    619      * @return true or false 
    620      */ 
    621     public function isDefaultNetwork() { 
     785     * @return bool True or false 
     786     * 
     787     * @access public 
     788     */ 
     789    public function isDefaultNetwork() 
     790    { 
    622791        ($this->mRow['is_default_network'] == 't') ? $retval = true : $retval = false; 
    623792        return $retval; 
    624793    } 
    625794 
    626     /** Set as the default network.  The can only be one default network, so this method will unset is_default_network for all other network 
    627      * @return true on success, false on failure */ 
    628     function setAsDefaultNetwork() { 
     795    /** 
     796     * Set as the default network. 
     797     * 
     798     * The can only be one default network, so this method will unset 
     799     * is_default_network for all other network 
     800     * 
     801     * @return bool True on success, false on failure 
     802     * 
     803     * @access public 
     804     */ 
     805    public function setAsDefaultNetwork() 
     806    { 
     807        // Init values 
    629808        $retval = true; 
     809 
    630810        if (!$this->isDefaultNetwork()) { 
    631811            global $db; 
     
    635815            $this->refresh(); 
    636816        } 
     817 
    637818        return $retval; 
    638819    } 
    639820 
    640     /** Retreives the network's validation grace period 
    641      * @return An integer (seconds) */ 
    642     public function getValidationGraceTime() { 
     821    /** 
     822     * Retreives the network's validation grace period 
     823     * 
     824     * @return int Network's validation grace period in seconds 
     825     * 
     826     * @access public 
     827     */ 
     828    public function getValidationGraceTime() 
     829    { 
    643830        return $this->mRow['validation_grace_time_seconds']; 
    644831    } 
    645832 
    646     /** Set the network's validation grace period in seconds.  A new user is granted Internet access for this period check his email and validate his account. 
    647      * @param $value The new value 
    648      * @return true on success, false on failure */ 
    649     function setValidationGraceTime($value) { 
     833    /** 
     834     * Set the network's validation grace period in seconds. 
     835     * 
     836     * A new user is granted Internet access for this period check his email 
     837     * and validate his account. 
     838     * 
     839     * @param int $value The new value 
     840     * 
     841     * @return bool True on success, false on failure 
     842     * 
     843     * @access public 
     844     */ 
     845    public function setValidationGraceTime($value) 
     846    { 
     847        // Init values 
    650848        $retval = true; 
     849 
    651850        if ($value != $this->getValidationGraceTime()) { 
    652851            global $db; 
     
    655854            $this->refresh(); 
    656855        } 
     856 
    657857        return $retval; 
    658858    } 
    659859 
    660     /** Retreives the FROM adress of the validation email 
    661      * @return A string */ 
    662     public function getValidationEmailFromAddress() { 
     860    /** 
     861     * Retreives the FROM adress of the validation email 
     862     * 
     863     * @return string A string 
     864     * 
     865     * @access public 
     866     */ 
     867    public function getValidationEmailFromAddress() 
     868    { 
    663869        return $this->mRow['validation_email_from_address']; 
    664870    } 
    665871 
    666     /** Set the FROM adress of the validation email 
    667      * @param $value The new value 
    668      * @return true on success, false on failure */ 
    669     function setValidationEmailFromAddress($value) { 
     872    /** 
     873     * Set the FROM adress of the validation email 
     874     * 
     875     * @param string $value The new value 
     876     * 
     877     * @return bool True on success, false on failure 
     878     * 
     879     * @access public 
     880     */ 
     881    public function setValidationEmailFromAddress($value) 
     882    { 
     883        // Init values 
    670884        $retval = true; 
     885 
    671886        if ($value != $this->getValidationEmailFromAddress()) { 
    672887            global $db; 
     
    675890            $this->refresh(); 
    676891        } 
     892 
    677893        return $retval; 
    678894    } 
    679895 
    680     /** Can an account be connected more than once at the same time? 
    681      * @return true or false */ 
    682     public function getMultipleLoginAllowed() { 
     896    /** 
     897     * Can an account be connected more than once at the same time? 
     898     * 
     899     * @return bool True or false 
     900     * 
     901     * @access public 
     902     */ 
     903    public function getMultipleLoginAllowed() 
     904    { 
    683905        return ($this->mRow['allow_multiple_login'] == 't') ? true : false; 
    684906    } 
    685907 
    686     /** Set if a account be connected more than once at the same time? 
    687      * @param $value The new value, true or false 
    688      * @return true on success, false on failure */ 
    689     function setMultipleLoginAllowed($value) { 
     908    /** 
     909     * Set if a account be connected more than once at the same time 
     910     * 
     911     * @param bool $value The new value, true or false 
     912     * 
     913     * @return bool true on success, false on failure 
     914     * 
     915     * @access public 
     916     */ 
     917    public function setMultipleLoginAllowed($value) 
     918    { 
     919        // Init values 
    690920        $retval = true; 
     921 
    691922        if ($value != $this->getMultipleLoginAllowed()) { 
    692923            global $db; 
     
    695926            $this->refresh(); 
    696927        } 
     928 
    697929        return $retval; 
    698930    } 
    699931 
    700     /** Are nodes allowed to be set as splash-only (no login)? 
    701      * @return true or false */ 
    702     public function getSplashOnlyNodesAllowed() { 
     932    /** 
     933     * Are nodes allowed to be set as splash-only (no login)? 
     934     * 
     935     * @return bool True or false 
     936     * 
     937     * @access public 
     938     */ 
     939    public function getSplashOnlyNodesAllowed() 
     940    { 
    703941        return (($this->mRow['allow_splash_only_nodes'] == 't') ? true : false); 
    704942    } 
    705943 
    706     /** Set if nodes are allowed to be set as splash-only (no login) 
    707      * @param $value The new value, true or false 
    708      * @return true on success, false on failure */ 
    709     function setSplashOnlyNodesAllowed($value) { 
     944    /** 
     945     * Set if nodes are allowed to be set as splash-only (no login) 
     946     * 
     947     * @param bool $value The new value, true or false 
     948     * 
     949     * @return bool True on success, false on failure 
     950     * 
     951     * @access public 
     952     */ 
     953    public function setSplashOnlyNodesAllowed($value) 
     954    { 
     955        // Init values 
    710956        $retval = true; 
     957 
    711958        if ($value != $this->getSplashOnlyNodesAllowed()) { 
    712959            global $db; 
     
    715962            $this->refresh(); 
    716963        } 
     964 
    717965        return $retval; 
    718966    } 
     
    725973     * @access public 
    726974     */ 
    727     public function getGisLocation() { 
     975    public function getGisLocation() 
     976    { 
    728977        return new GisPoint($this->mRow['gmaps_initial_latitude'], $this->mRow['gmaps_initial_longitude'], $this->mRow['gmaps_initial_zoom_level']); 
    729978    } 
     
    738987     * @access public 
    739988     */ 
    740     public function setGisLocation($pt) { 
     989    public function setGisLocation($pt) 
     990    { 
    741991        // Define globals 
    742992        global $db; 
     
    7651015     * @access public 
    7661016     */ 
    767     public function getGisMapType() { 
     1017    public function getGisMapType() 
     1018    { 
    7681019        return $this->mRow['gmaps_map_type']; 
    7691020    } 
     
    7781029     * @access public 
    7791030     */ 
    780     public function setGisMapType($value) { 
     1031    public function setGisMapType($value) 
     1032    { 
    7811033        // Define globals 
    7821034        global $db; 
     
    8071059     * @access public 
    8081060     */ 
    809     public static function getSelectGisMapType($user_prefix, $pre_selected_map_type = "G_NORMAL_MAP") { 
    810             // Define globals 
    811     global $db; 
     1061    public static function getSelectGisMapType($user_prefix, $pre_selected_map_type = "G_NORMAL_MAP") 
     1062    { 
     1063        // Define globals 
     1064        global $db; 
    8121065 
    8131066        // Init values 
     
    8281081    } 
    8291082 
    830     /** Get's the splash-only user.  This is the user that people logged-in at a splash-only hotspot will show up as.  This user always has multiple-login capabilities. 
    831     * @param $username The username of the user 
    832     * @param $account_origin The account origin 
    833     * @return a User object 
    834     */ 
    835     public function getSplashOnlyUser() { 
     1083    /** 
     1084     * Get's the splash-only user. 
     1085     * 
     1086     * This is the user that people logged-in at a splash-only hotspot will 
     1087     * show up as.  This user always has multiple-login capabilities. 
     1088     * 
     1089     * @param string $username The username of the user 
     1090     * @param string $account_origin The account origin 
     1091     * 
     1092     * @return object A User object 
     1093     * 
     1094     * @access public 
     1095     */ 
     1096    public function getSplashOnlyUser() 
     1097    { 
    8361098        $username = 'SPLASH_ONLY_USER'; 
    8371099 
     
    8511113     * @access public 
    8521114     */ 
    853     public function getNumUsers() { 
     1115    public function getNumUsers() 
     1116    { 
    8541117        // Define globals 
    8551118        global $db; 
     
    9001163     * @access public 
    9011164     */ 
    902     public function getNumValidUsers() { 
     1165    public function getNumValidUsers() 
     1166    { 
    9031167        // Define globals 
    9041168        global $db; 
     
    9501214     * @access public 
    9511215     */ 
    952     public function getNumOnlineUsers() { 
     1216    public function getNumOnlineUsers() 
     1217    { 
    9531218        // Define globals 
    9541219        global $db; 
     
    9991264     * @access public 
    10001265     */ 
    1001     public function getNumNodes() { 
     1266    public function getNumNodes() 
     1267    { 
    10021268        // Define globals 
    10031269        global $db; 
     
    10481314     * @access public 
    10491315     */ 
    1050     public function getNumDeployedNodes() { 
     1316    public function getNumDeployedNodes() 
     1317    { 
    10511318        // Define globals 
    10521319        global $db; 
     
    10931360     * Find out how many deployed nodes are online in this networks's database 
    10941361     * 
     1362     * @param bool $nonMonitoredOnly Return number of non-monitored nodes only 
     1363     * 
    10951364     * @return int Number of deployed nodes which are online 
    10961365     * 
    10971366     * @access public 
    10981367     */ 
    1099     public function getNumOnlineNodes() { 
     1368    public function getNumOnlineNodes($nonMonitoredOnly = false) 
     1369    { 
    11001370        // Define globals 
    11011371        global $db; 
     
    11081378 
    11091379        // Create new cache objects (valid for 5 minutes) 
    1110         $_cache = new Cache('network_'.$this->id.'_num_online_nodes', $this->id, 300); 
     1380        if ($nonMonitoredOnly) { 
     1381            $_cache = new Cache('network_'.$this->id.'_num_online_nodes_non_monitored', $this->id, 300); 
     1382        } else { 
     1383            $_cache = new Cache('network_'.$this->id.'_num_online_nodes', $this->id, 300); 
     1384        } 
    11111385 
    11121386        // Check if caching has been enabled. 
     
    11241398            // Get number of online nodes 
    11251399            $_network_id = $db->escapeString($this->id); 
    1126             $db->execSqlUniqueRes("SELECT COUNT(node_id) FROM nodes WHERE network_id = '$_network_id' AND (node_deployment_status = 'DEPLOYED' OR node_deployment_status = 'NON_WIFIDOG_NODE') AND ((NOW()-last_heartbeat_timestamp) < interval '5 minutes')", $_row, false); 
     1400 
     1401            if ($nonMonitoredOnly) { 
     1402                $db->execSqlUniqueRes("SELECT COUNT(node_id) FROM nodes WHERE network_id = '$_network_id' AND node_deployment_status = 'NON_WIFIDOG_NODE' AND ((NOW()-last_heartbeat_timestamp) >= interval '5 minutes')", $_row, false); 
     1403            } else { 
     1404                $db->execSqlUniqueRes("SELECT COUNT(node_id) FROM nodes WHERE network_id = '$_network_id' AND (node_deployment_status = 'DEPLOYED' OR node_deployment_status = 'NON_WIFIDOG_NODE') AND ((NOW()-last_heartbeat_timestamp) < interval '5 minutes')", $_row, false); 
     1405            } 
    11271406 
    11281407            // String has been found 
     
    11391418    } 
    11401419 
    1141     /** Are nodes allowed to redirect users to an arbitrary web page instead of the portal? 
    1142      * @return true or false */ 
    1143     public function getCustomPortalRedirectAllowed() { 
     1420    /** 
     1421     * Are nodes allowed to redirect users to an arbitrary web page instead of 
     1422     * the portal? 
     1423     * 
     1424     * @return bool True or false 
     1425     * 
     1426     * @access public 
     1427     */ 
     1428    public function getCustomPortalRedirectAllowed() 
     1429    { 
    11441430        return (($this->mRow['allow_custom_portal_redirect'] == 't') ? true : false); 
    11451431    } 
    11461432 
    1147     /** Set if nodes are allowed to redirect users to an arbitrary web page instead of the portal? 
    1148      * @param $value The new value, true or false 
    1149      * @return true on success, false on failure */ 
    1150     function setCustomPortalRedirectAllowed($value) { 
     1433    /** 
     1434     * Set if nodes are allowed to redirect users to an arbitrary web page 
     1435     * instead of the portal? 
     1436     * 
     1437     * @param bool $value The new value, true or false 
     1438     * 
     1439     * @return bool True on success, false on failure 
     1440     * 
     1441     * @access public 
     1442     */ 
     1443    public function setCustomPortalRedirectAllowed($value) 
     1444    { 
     1445        // Init values 
    11511446        $retval = true; 
     1447 
    11521448        if ($value != $this->getCustomPortalRedirectAllowed()) { 
    11531449            global $db; 
     
    11561452            $this->refresh(); 
    11571453        } 
     1454 
    11581455        return $retval; 
    11591456    } 
     
    11611458    /** 
    11621459     * Does the user have admin access to this network? 
    1163      * @return boolean true our false 
    1164      */ 
    1165     function hasAdminAccess(User $user) { 
     1460     * 
     1461     * @return bool true our false 
     1462     * 
     1463     * @access public 
     1464     */ 
     1465    public function hasAdminAccess(User $user) 
     1466    { 
    11661467        // Define globals 
    11671468        global $db; 
     
    12031504        // Define globals 
    12041505        global $db; 
    1205      
     1506 
    12061507        // Init values 
    12071508        $content_rows = null; 
    12081509        $retval = array (); 
    1209      
     1510 
    12101511        // Get all network, but exclude user subscribed content if asked 
    12111512        if ($exclude_subscribed_content == true && $subscriber) { 
     
    12141515                $sql = "SELECT content_id FROM network_has_content WHERE network_id='$this->id' ORDER BY subscribe_timestamp DESC"; 
    12151516        } 
    1216      
     1517 
    12171518        $db->execSql($sql, $content_rows, false); 
    1218      
     1519 
    12191520        if ($content_rows != null) { 
    12201521                foreach ($content_rows as $content_row) { 
     
    12221523                } 
    12231524        } 
    1224      
     1525 
    12251526        return $retval; 
    12261527    } 
    12271528    */ 
     1529 
    12281530    /** 
    12291531     * Retreives the admin interface of this object 
     
    12331535     * @access public 
    12341536     */ 
    1235     public function getAdminUI() { 
     1537    public function getAdminUI() 
     1538    { 
     1539        // Init values 
    12361540        $html = ''; 
     1541 
     1542                /* 
     1543                 * Begin with admin interface 
     1544                 */ 
    12371545        $html .= "<fieldset class='admin_container ".get_class($this)."'>\n"; 
    12381546        $html .= "<legend>"._("Network management")."</legend>\n"; 
    12391547        $html .= "<ul class='admin_element_list'>\n"; 
    12401548 
    1241         // Content management 
     1549        /* 
     1550         * Content management 
     1551         */ 
    12421552        $title = _("Network content"); 
    12431553        $name = "network_".$this->id."_content"; 
    1244         $data = Content :: getLinkedContentUI($name, "network_has_content", "network_id", $this->id, $display_page = "portal"); 
    1245         $html .= InterfaceElements :: generateAdminSectionContainer("network_content", $title, $data); 
     1554        $data = Content::getLinkedContentUI($name, "network_has_content", "network_id", $this->id, $display_page = "portal"); 
     1555        $html .= InterfaceElements::generateAdminSectionContainer("network_content", $title, $data); 
     1556 
     1557        /* 
     1558         * Network information 
     1559         */ 
     1560                $html_network_information = array(); 
    12461561 
    12471562        // network_id 
    1248         $html .= "<li class='admin_element_item_container'>\n"; 
    1249         $html .= "<div class='admin_element_label'>"._("Network ID")." : </div>\n"; 
    1250         $html .= "<div class='admin_element_data'>\n"; 
    1251         $value = htmlspecialchars($this->getId(), ENT_QUOTES); 
    1252         $html .= $value; 
    1253         $html .= "</div>\n"; 
    1254         $html .= "</li>\n"; 
     1563                $title = _("Network ID"); 
     1564        $data = htmlspecialchars($this->getId(), ENT_QUOTES); 
     1565                $html_network_information[] = InterfaceElements::generateAdminSectionContainer("network_id", $title, $data); 
    12551566 
    12561567        // name 
    1257         $html .= "<li class='admin_element_item_container'>\n"; 
    1258         $html .= "<div class='admin_element_label'>"._("Network name")." : </div>\n"; 
    1259         $html .= "<div class='admin_element_data'>\n"; 
    1260         $name = "network_".$this->getId()."_name"; 
    1261         $value = htmlspecialchars($this->getName(), ENT_QUOTES); 
    1262         $html .= "<input type='text' size ='50' value='$value' name='$name'>\n"; 
    1263         $html .= "</div>\n"; 
    1264         $html .= "</li>\n"; 
     1568                $title = _("Network name"); 
     1569                $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_name", $this->getName(), "network_name_input"); 
     1570                $html_network_information[] = InterfaceElements::generateAdminSectionContainer("network_name", $title, $data); 
    12651571 
    12661572        // creation_date 
    1267         $name = "network_".$this->getId()."_creation_date"; 
    1268         $value = htmlspecialchars($this->getCreationDate(), ENT_QUOTES); 
    1269  
    1270         $html .= "<li class='admin_element_item_container'>\n"; 
    1271         $html .= "<div class='admin_element_label'>"._("Network creation date").":</div>\n"; 
    1272         $html .= "<div class='admin_element_data'>\n"; 
    1273         $html .= "<input type='text' size ='50' value='$value' name='$name'>\n"; 
    1274         $html .= "</div>\n"; 
    1275         $html .= "</li>\n"; 
    1276          
     1573                $title = _("Network creation date"); 
     1574        $data = DateTime::getSelectDateTimeUI(new DateTime($this->getCreationDate()), "network_" . $this->getId() . "_creation_date", DateTime::INTERFACE_DATETIME_FIELD, "network_creation_date_input"); 
     1575                $html_network_information[] = InterfaceElements::generateAdminSectionContainer("network_creation_date", $title, $data); 
     1576 
    12771577        // homepage_url 
    1278         $html .= "<li class='admin_element_item_container'>\n"; 
    1279         $html .= "<div class='admin_element_label'>"._("Network's web site")." : </div>\n"; 
    1280         $html .= "<div class='admin_element_data'>\n"; 
    1281         $name = "network_".$this->getId()."_homepage_url"; 
    1282         $value = htmlspecialchars($this->getHomepageURL(), ENT_QUOTES); 
    1283         $html .= "<input type='text' size ='50' value='$value' name='$name'>\n"; 
    1284         $html .= "</div>\n"; 
    1285         $html .= "</li>\n"; 
     1578                $title = _("Network's web site"); 
     1579                $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_homepage_url", $this->getHomepageURL(), "network_homepage_url_input"); 
     1580                $html_network_information[] = InterfaceElements::generateAdminSectionContainer("network_homepage_url", $title, $data); 
    12861581 
    12871582        // tech_support_email 
    1288         $html .= "<li class='admin_element_item_container'>\n"; 
    1289         $html .= "<div class='admin_element_label'>"._("Technical support email")." : </div>\n"; 
    1290         $html .= "<div class='admin_element_data'>\n"; 
    1291         $name = "network_".$this->getId()."_tech_support_email"; 
    1292         $value = htmlspecialchars($this->getTechSupportEmail(), ENT_QUOTES); 
    1293         $html .= "<input type='text' size ='50' value='$value' name='$name'>\n"; 
    1294         $html .= "</div>\n"; 
    1295         $html .= "</li>\n"; 
     1583                $title = _("Technical support email"); 
     1584                $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_tech_support_email", $this->getTechSupportEmail(), "network_tech_support_email_input"); 
     1585                $html_network_information[] = InterfaceElements::generateAdminSectionContainer("network_tech_support_email", $title, $data); 
     1586 
     1587                // Build section 
     1588                $html .= InterfaceElements::generateAdminSectionContainer("network_information", _("Information about the network"), implode(null, $html_network_information)); 
     1589 
     1590        /* 
     1591         * Network authentication 
     1592         */ 
     1593                $html_network_authentication = array(); 
    12961594 
    12971595        //  network_authenticator_class 
    1298         $html .= "<li class='admin_element_item_container'>\n"; 
    1299         $html .= "<div class='admin_element_label'>"._("Network authenticator class.  The subclass of Authenticator to be used for user authentication (ex: AuthenticatorRadius)")." : </div>\n"; 
    1300         $html .= "<div class='admin_element_data'>\n"; 
    1301         $name = "network_".$this->getId()."_network_authenticator_class"; 
     1596                $title = _("Network authenticator class"); 
     1597                $help = _("The subclass of Authenticator to be used for user authentication. Example: AuthenticatorRadius"); 
     1598        $name = "network_" . $this->getId() . "_network_authenticator_class"; 
    13021599        $value = htmlspecialchars($this->getAuthenticatorClassName(), ENT_QUOTES); 
    1303         $html .= $this->getSelectAuthenticator($name, $value); 
    1304         $html .= "</div>\n"; 
    1305         $html .= "</li>\n"; 
     1600        $data = $this->getSelectAuthenticator($name, $value); 
     1601                $html_network_authentication[] = InterfaceElements::generateAdminSectionContainer("network_network_authenticator_class", $title, $data, $help); 
    13061602 
    13071603        //  network_authenticator_params 
    1308         $html .= "<li class='admin_element_item_container'>\n"; 
    1309         $html .= "<div class='admin_element_label'>"._("The explicit parameters to be passed to the authenticator (ex: 'my_network_id', '192.168.0.11', 1812, 1813, 'secret_key', 'CHAP_MD5')")." : </div>\n"; 
    1310         $html .= "<div class='admin_element_data'>\n"; 
    1311         $name = "network_".$this->getId()."_network_authenticator_params"; 
    1312         $value = htmlspecialchars($this->getAuthenticatorConstructorParams(), ENT_QUOTES); 
    1313         $html .= "<input type='text' size ='50' value='$value' name='$name'>\n"; 
    1314         $html .= "</div>\n"; 
    1315         $html .= "</li>\n"; 
     1604                $title = _("Authenticator parameters"); 
     1605        $help = _("The explicit parameters to be passed to the authenticator. Example: 'my_network_id', '192.168.0.11', 1812, 1813, 'secret_key', 'CHAP_MD5'"); 
     1606                $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_network_authenticator_params", $this->getAuthenticatorConstructorParams(), "network_network_authenticator_params_input"); 
     1607                $html_network_authentication[] = InterfaceElements::generateAdminSectionContainer("network_network_authenticator_params", $title, $data, $help); 
     1608 
     1609                // Build section 
     1610                $html .= InterfaceElements::generateAdminSectionContainer("network_authentication", _("Network Authentication"), implode(null, $html_network_authentication)); 
     1611 
     1612        /* 
     1613         * Network properties 
     1614         */ 
     1615                $html_network_properties = array(); 
    13161616 
    13171617        //  is_default_network 
    1318         $html .= "<li class='admin_element_item_container'>\n"; 
    1319         $html .= "<div class='admin_element_label'>"._("Is this network the default network?")." : </div>\n"; 
    1320         $html .= "<div class='admin_element_data'>\n"; 
    1321         $name = "network_".$this->getId()."_is_default_network"; 
    1322         $this->isDefaultNetwork() ? $checked = 'CHECKED' : $checked = ''; 
    1323         $html .= "<input type='checkbox' name='$name' $checked>\n"; 
    1324         $html .= "</div>\n"; 
    1325         $html .= "</li>\n"; 
     1618                $title = _("Is this network the default network?"); 
     1619                $data = InterfaceElements::generateInputCheckbox("network_" . $this->getId() . "_is_default_network", "", _("Yes"), $this->isDefaultNetwork(), "network_is_default_network_radio"); 
     1620                $html_network_properties[] = InterfaceElements::generateAdminSectionContainer("network_is_default_network", $title, $data); 
     1621 
     1622        //  theme_pack 
     1623                $title = _("Selected theme pack for this network"); 
     1624        $data = ThemePack::getSelectUI("network_" . $this->getId() . "_theme_pack", $this->getThemePack()); 
     1625                $html_network_properties[] = InterfaceElements::generateAdminSectionContainer("network_theme_pack", $title, $data); 
     1626 
     1627                // Build section 
     1628                $html .= InterfaceElements::generateAdminSectionContainer("network_properties", _("Network properties"), implode(null, $html_network_properties)); 
     1629 
     1630        /* 
     1631         * Network's node properties 
     1632         */ 
     1633                $html_network_node_properties = array(); 
     1634 
     1635        //  allow_splash_only_nodes 
     1636                $title = _("Splash-only nodes"); 
     1637                $help = _("Are nodes allowed to be set as splash-only (no login)?"); 
     1638                $data = InterfaceElements::generateInputCheckbox("network_" . $this->getId() . "_allow_splash_only_nodes", "", _("Yes"), $this->getSplashOnlyNodesAllowed(), "network_allow_splash_only_nodes_radio"); 
     1639                $html_network_node_properties[] = InterfaceElements::generateAdminSectionContainer("network_allow_splash_only_nodes", $title, $data, $help); 
     1640 
     1641        //  allow_custom_portal_redirect 
     1642                $title = _("Portal page redirection"); 
     1643                $help = _("Are nodes allowed to redirect users to an arbitrary web page instead of the portal?"); 
     1644                $data = InterfaceElements::generateInputCheckbox("network_" . $this->getId() . "_allow_custom_portal_redirect", "", _("Yes"), $this->getCustomPortalRedirectAllowed(), "network_allow_custom_portal_redirect_radio"); 
     1645                $html_network_node_properties[] = InterfaceElements::generateAdminSectionContainer("network_allow_custom_portal_redirect", $title, $data, $help); 
     1646 
     1647                // Build section 
     1648                $html .= InterfaceElements::generateAdminSectionContainer("network_node_properties", _("Network's node properties"), implode(null, $html_network_node_properties)); 
     1649 
     1650        /* 
     1651         * Network's user verification 
     1652         */ 
     1653                $html_network_user_verification = array(); 
    13261654 
    13271655        //  validation_grace_time 
    1328         $html .= "<li class='admin_element_item_container'>\n"; 
    1329         $html .= "<div class='admin_element_label'>"._("The length of the validation grace period in seconds.  A new user is granted Internet access for this period check his email and validate his account.")." : </div>\n"; 
    1330         $html .= "<div class='admin_element_data'>\n"; 
    1331         $name = "network_".$this->getId()."_validation_grace_time"; 
    1332         $value = htmlspecialchars($this->getValidationGraceTime(), ENT_QUOTES); 
    1333         $html .= "<input type='text' size ='5' value='$value' name='$name'>\n"; 
    1334         $html .= "</div>\n"; 
    1335         $html .= "</li>\n"; 
     1656                $title = _("Validation grace period"); 
     1657        $help = _("The length of the validation grace period in seconds.  A new user is granted Internet access for this period check his email and validate his account."); 
     1658                $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_validation_grace_time", $this->getValidationGraceTime(), "network_validation_grace_time_input"); 
     1659                $html_network_user_verification[] = InterfaceElements::generateAdminSectionContainer("network_validation_grace_time", $title, $data, $help); 
    13361660 
    13371661        //  validation_email_from_address 
    1338         $html .= "<li class='admin_element_item_container'>\n"; 
    1339         $html .= "<div class='admin_element_label'>"._("This will be the from adress of the validation email")." : </div>\n"; 
    1340         $html .= "<div class='admin_element_data'>\n"; 
    1341         $name = "network_".$this->getId()."_validation_email_from_address"; 
    1342         $value = htmlspecialchars($this->getValidationEmailFromAddress(), ENT_QUOTES); 
    1343         $html .= "<input type='text' size ='50' value='$value' name='$name'>\n"; 
    1344         $html .= "</div>\n"; 
    1345         $html .= "</li>\n"; 
    1346  
    1347         //  theme_pack 
    1348         $html .= "<li class='admin_element_item_container'>\n"; 
    1349         $html .= "<div class='admin_element_label'>"._("Selected theme pack for this network")." : </div>\n"; 
    1350         $html .= "<div class='admin_element_data'>\n"; 
    1351         $name = "network_".$this->getId()."_theme_pack"; 
    1352         $html .= ThemePack :: getSelectUI($name, $this->getThemePack()); 
    1353         $html .= "</div>\n"; 
    1354         $html .= "</li>\n"; 
     1662                $title = _("This will be the from adress of the validation email"); 
     1663                $data = InterfaceElements::generateInputText("network_" . $this->getId() . "_validation_email_from_address", $this->getValidationEmailFromAddress(), "network_validation_email_from_address_input"); 
     1664                $html_network_user_verification[] = InterfaceElements::generateAdminSectionContainer("network_validation_email_from_address", $title, $data); 
    13551665 
    13561666        //  allow_multiple_login 
    1357         $html .= "<li class='admin_element_item_container'>\n"; 
    1358         $html .= "<div class='admin_element_label'>"._("Can an account be connected more than once at the same time?")." : </div>\n"; 
    1359         $html .= "<div class='admin_element_data'>\n"; 
    1360         $name = "network_".$this->getId()."_allow_multiple_login"; 
    1361         $this->getMultipleLoginAllowed() ? $checked = 'CHECKED' : $checked = ''; 
    1362         $html .= "<input type='checkbox' name='$name' $checked>\n"; 
    1363         $html .= "</div>\n"; 
    1364         $html .= "</li>\n"; 
    1365  
    1366         //  allow_splash_only_nodes 
    1367         $html .= "<li class='admin_element_item_container'>\n"; 
    1368         $html .= "<div class='admin_element_label'>"._("Are nodes allowed to be set as splash-only (no login)?")." : </div>\n"; 
    1369         $html .= "<div class='admin_element_data'>\n"; 
    1370         $name = "network_".$this->getId()."_allow_splash_only_nodes"; 
    1371         $this->getSplashOnlyNodesAllowed() ? $checked = 'CHECKED' : $checked = ''; 
    1372         $html .= "<input type='checkbox' name='$name' $checked>\n"; 
    1373         $html .= "</div>\n"; 
    1374         $html .= "</li>\n"; 
    1375  
    1376         //  allow_custom_portal_redirect 
    1377         $html .= "<li class='admin_element_item_container'>\n"; 
    1378         $html .= "<div class='admin_element_label'>"._("Are nodes allowed to redirect users to an arbitrary web page instead of the portal?")." : </div>\n"; 
    1379         $html .= "<div class='admin_element_data'>\n"; 
    1380         $name = "network_".$this->getId()."_allow_custom_portal_redirect"; 
    1381         $this->getCustomPortalRedirectAllowed() ? $checked = 'CHECKED' : $checked = ''; 
    1382         $html .= "<input type='checkbox' name='$name' $checked>\n"; 
    1383         $html .= "</div>\n"; 
    1384         $html .= "</li>\n"; 
     1667                $title = _("Multiple connections"); 
     1668                $help = _("Can an account be connected more than once at the same time?"); 
     1669                $data = InterfaceElements::generateInputCheckbox("network_" . $this->getId() . "_allow_multiple_login", "", _("Yes"), $this->getMultipleLoginAllowed(), "network_allow_multiple_login_radio"); 
     1670                $html_network_user_verification[] = InterfaceElements::generateAdminSectionContainer("network_allow_multiple_login", $title, $data, $help); 
     1671 
     1672                // Build section 
     1673                $html .= InterfaceElements::generateAdminSectionContainer("network_user_verification", _("Network's user verification"), implode(null, $html_network_user_verification)); 
     1674 
     1675                /* 
     1676                 * Access management 
     1677                 */ 
     1678                $html_access_rights = array(); 
    13851679 
    13861680        //      network_stakeholders 
    1387         $html .= "<li class='admin_element_item_container'>\n"; 
    1388         $html .= "<div class='admin_element_label'>"._("Network stakeholders")." : </div>\n"; 
    1389         $html .= "<div class='admin_element_data'>\n"; 
    1390         //$name = "network_".$this->getId()."_allow_custom_portal_redirect"; 
    1391         //$this->getCustomPortalRedirectAllowed()? $checked='CHECKED': $checked=''; 
    1392         //$html .= "<input type='checkbox' name='$name' $checked>\n"; 
    1393         $html .= "WRITEME!"; 
    1394         $html .= "</div>\n"; 
    1395         $html .= "</li>\n"; 
    1396  
    1397         // Build HTML form fields names & values 
     1681                $title = _("Network stakeholders"); 
     1682        $data = "WRITEME!"; 
     1683                $html_access_rights[] = InterfaceElements::generateAdminSectionContainer("network_stakeholders", $title, $data); 
     1684 
     1685                // Build section 
     1686                $html .= InterfaceElements::generateAdminSectionContainer("network_access_rights", _("Access rights"), implode(null, $html_access_rights)); 
     1687 
     1688                /* 
     1689                 * Network GIS data 
     1690                 */ 
    13981691        if (defined('GMAPS_HOTSPOTS_MAP_ENABLED') && GMAPS_HOTSPOTS_MAP_ENABLED == true) { 
     1692                $html_network_gis_data = array(); 
     1693 
    13991694            $gis_point = $this->getGisLocation(); 
    1400             $gis_lat_name = "network_".$this->getId()."_gis_latitude"; 
     1695            $gis_lat_name = "network_" . $this->getId() . "_gis_latitude"; 
    14011696            $gis_lat_value = htmlspecialchars($gis_point->getLatitude(), ENT_QUOTES); 
    1402             $gis_long_name = "network_".$this->getId()."_gis_longitude"; 
     1697            $gis_long_name = "network_" . $this->getId() . "_gis_longitude"; 
    14031698            $gis_long_value = htmlspecialchars($gis_point->getLongitude(), ENT_QUOTES); 
    1404             $gis_alt_name = "network_".$this->getId()."_gis_altitude"; 
     1699            $gis_alt_name = "network_" . $this->getId() . "_gis_altitude"; 
    14051700            $gis_alt_value = htmlspecialchars($gis_point->getAltitude(), ENT_QUOTES); 
    14061701 
    1407             $html .= "<li class='admin_element_item_container'>\n"; 
    1408             $html .= "<div class='admin_element_label'>"._("Center latitude for your the area of your wireless network")." : </div>\n"; 
    1409             $html .= "<div class='admin_element_data'>\n"; 
    1410             $html .= "<input type='text' size ='15' value='$gis_lat_value' id='$gis_lat_name' name='$gis_lat_name'>\n"; 
    1411             $html .= "</div>\n"; 
    1412             $html .= "</li>\n"; 
    1413  
    1414             $html .= "<li class='admin_element_item_container'>\n"; 
    1415             $html .= "<div class='admin_element_label'>"._("Center longitude for your the area of your wireless network")." : </div>\n"; 
    1416             $html .= "<div class='admin_element_data'>\n"; 
    1417             $html .= "<input type='text' size ='15' value='$gis_long_value' id='$gis_long_name' name='$gis_long_name'>\n"; 
    1418             $html .= "</div>\n"; 
    1419             $html .= "</li>\n"; 
    1420  
    1421             $html .= "<li class='admin_element_item_container'>\n"; 
    1422             $html .= "<div class='admin_element_label'>"._("Zoomlevel of the Google Map for your the area of your wireless network")." : </div>\n"; 
    1423             $html .= "<div class='admin_element_data'>\n"; 
    1424             $html .= "<input type='text' size ='15' value='$gis_alt_value' id='$gis_alt_name' name='$gis_alt_name'>\n"; 
    1425             $html .= "</div>\n"; 
    1426             $html .= "</li>\n"; 
    1427  
    1428             $html .= "<li class='admin_element_item_container'>\n"; 
    1429             $html .= "<div class='admin_element_label'>"._("Default Google Map type for your the area of your wireless network")." : </div>\n"; 
    1430             $html .= "<div class='admin_element_data'>\n"; 
    1431             $html .= $this->getSelectGisMapType("network_".$this->getId()."_gmaps_map_type", $this->getGisMapType()); 
    1432             $html .= "</div>\n"; 
    1433             $html .= "</li>\n"; 
    1434         } 
    1435  
    1436         // Create new nodes 
    1437         $html .= "<li class='admin_element_item_container'>\n"; 
    1438         $html .= "<div class='admin_element_label'>"._("New node ID")." : </div>\n"; 
    1439  
    1440         $html .= "<div class='admin_element_data'>\n"; 
    1441  
    1442         $html .= Node :: getCreateNewObjectUI($this); 
    1443         $html .= "</div>\n"; 
    1444                 $html .= "<div class='admin_element_tools'>\n"; 
    1445         $name = "network_{$this->getId()}_create_node"; 
    1446         $html .= "<input type='submit' name='{$name}' value='"._("Create a new node")."'>\n"; 
    1447         $html .= "</div>\n"; 
    1448         $html .= "</li>\n"; 
     1702                $title = _("Latitude"); 
     1703                $help = _("Center latitude for your the area of your wireless network"); 
     1704                $data = InterfaceElements::generateInputText($gis_lat_name, $gis_lat_value, "network_gis_latitude_input"); 
     1705                $html_network_gis_data[] = InterfaceElements::generateAdminSectionContainer("network_gis_latitude", $title, $data, $help); 
     1706 
     1707                $title = _("Longitude"); 
     1708                $help = _("Center longitude for your the area of your wireless network"); 
     1709                $data = InterfaceElements::generateInputText($gis_long_name, $gis_long_value, "network_gis_longitude_input"); 
     1710                $html_network_gis_data[] = InterfaceElements::generateAdminSectionContainer("network_gis_longitude", $title, $data, $help); 
     1711 
     1712                $title = _("Zoomlevel"); 
     1713                $help = _("Zoomlevel of the Google Map for your the area of your wireless network"); 
     1714                $data = InterfaceElements::generateInputText($gis_alt_name, $gis_alt_value, "network_gis_altitude_input"); 
     1715                $html_network_gis_data[] = InterfaceElements::generateAdminSectionContainer("network_gis_altitude", $title, $data, $help); 
     1716 
     1717                $title = _("Map type"); 
     1718                $help = _("Default Google Map type for your the area of your wireless network"); 
     1719                $data = $this->getSelectGisMapType("network_" . $this->getId() . "_gmaps_map_type", $this->getGisMapType()); 
     1720                $html_network_gis_data[] = InterfaceElements::generateAdminSectionContainer("network_gmaps_map_type", $title, $data, $help); 
     1721 
     1722                // Build section 
     1723                $html .= InterfaceElements::generateAdminSectionContainer("network_gis_data", _("GIS data"), implode(null, $html_network_gis_data)); 
     1724        } 
    14491725 
    14501726        $html .= "</ul>\n"; 
    1451         $html .= "</fieldset>\n"; 
     1727        $html .= "</fieldset>"; 
     1728 
    14521729        return $html; 
    14531730    } 
    14541731 
    1455     /** Process admin interface of this object. 
    1456     */ 
    1457     public function processAdminUI() { 
    1458         //pretty_print_r($_REQUEST); 
    1459         $user = User :: getCurrentUser(); 
    1460         if (!$this->hasAdminAccess($user)) { 
    1461             throw new Exception(_('Access denied!')); 
    1462         } 
    1463          
     1732    /** 
     1733     * Process admin interface of this object. 
     1734     * 
     1735     * @return void 
     1736     * 
     1737     * @access public 
     1738     */ 
     1739    public function processAdminUI() 
     1740    { 
     1741        $user = User::getCurrentUser(); 
     1742 
     1743        try { 
     1744            if (!$this->hasAdminAccess($user)) { 
     1745                throw new Exception(_('Access denied!')); 
     1746            } 
     1747        } catch (Exception $e) { 
     1748            $ui = new MainUI(); 
     1749            $ui->setToolSection('ADMIN'); 
     1750            $ui->displayError($e->getMessage(), false); 
     1751            exit; 
     1752        } 
     1753 
    14641754        // Content management 
    14651755        $name = "network_".$this->id."_content"; 
     
    14691759        $name = "network_".$this->getId()."_name"; 
    14701760        $this->setName($_REQUEST[$name]); 
    1471          
     1761 
    14721762        // creation_date 
    14731763        $name = "network_".$this->getId()."_creation_date"; 
     
    15441834    } 
    15451835 
    1546     /** Add network-wide content to this network */ 
    1547     public function addContent(Content $content) { 
    1548         global $db; 
     1836    /** 
     1837     * Add network-wide content to this network 
     1838     * 
     1839     * @param object Content object 
     1840     * 
     1841     * @return void 
     1842     * 
     1843     * @access public 
     1844     */ 
     1845    public function addContent(Content $content) 
     1846    { 
     1847        // Define globals 
     1848        global $db; 
     1849 
    15491850        $content_id = $db->escapeString($content->getId()); 
    15501851        $sql = "INSERT INTO network_has_content (network_id, content_id) VALUES ('$this->id','$content_id')"; 
     
    15521853    } 
    15531854 
    1554     /** Remove network-wide content from this network */ 
    1555     public function removeContent(Content $content) { 
    1556         global $db; 
     1855    /** 
     1856     * Remove network-wide content from this network 
     1857     * 
     1858     * @param object Content object 
     1859     * 
     1860     * @return void 
     1861     * 
     1862     * @access public 
     1863     */ 
     1864    public function removeContent(Content $content) 
     1865    { 
     1866        // Define globals 
     1867        global $db; 
     1868 
    15571869        $content_id = $db->escapeString($content->getId()); 
    15581870        $sql = "DELETE FROM network_has_content WHERE network_id='$this->id' AND content_id='$content_id'"; 
     
    15601872    } 
    15611873 
    1562     /** Delete this Object form the it's storage mechanism 
    1563      * @param &$errmsg Returns an explanation of the error on failure 
    1564      * @return true on success, false on failure or access denied */ 
    1565     public function delete(& $errmsg) { 
     1874    /** 
     1875     * Delete this Object form the it's storage mechanism 
     1876     * 
     1877     * @param string &$errmsg Returns an explanation of the error on failure 
     1878     * 
     1879     * @return bool true on success, false on failure or access denied 
     1880     * 
     1881     * @access public 
     1882     */ 
     1883    public function delete(& $errmsg) 
     1884    { 
     1885        // Init values 
    15661886        $retval = false; 
     1887 
    15671888        $user = User :: getCurrentUser(); 
    15681889        if (!$user->isSuperAdmin()) { 
    15691890            $errmsg = _('Access denied (must have super admin access)'); 
    1570         } 
    1571         else { 
    1572             if ($this->isDefaultNetwork() === true) 
     1891        } else { 
     1892            if ($this->isDefaultNetwork() === true) { 
    15731893                $errmsg = _('Cannot delete default network, create another one and select it before remove this one.'); 
    1574             else { 
     1894            } else { 
    15751895                global $db; 
    15761896                $id = $db->escapeString($this->getId()); 
    15771897                if (!$db->execSqlUpdate("DELETE FROM networks WHERE network_id='{$id}'", false)) { 
    15781898                    $errmsg = _('Could not delete network!'); 
    1579                 } 
    1580                 else { 
     1899                } else { 
    15811900                    $retval = true; 
    15821901                } 
    15831902            } 
    15841903        } 
     1904 
    15851905        return $retval; 
    15861906    } 
    1587     /** Reloads the object from the database.  Should normally be called after a set operation */ 
    1588     protected function refresh() { 
     1907    /** 
     1908     * Reloads the object from the database. 
     1909     * 
     1910     * Should normally be called after a set operation 
     1911     * 
     1912     * @return void 
     1913     * 
     1914     * @access protected 
     1915     */ 
     1916    protected function refresh() 
     1917    { 
    15891918        $this->__construct($this->id); 
    15901919    } 
    15911920 
    1592     public static function assignSmartyValues($smarty, $net = null) { 
    1593         if (!$net) 
    1594             $net = Network :: getCurrentNetwork(); 
    1595  
     1921    /** 
     1922     * Assigns values about network to be processed by the Smarty engine. 
     1923     * 
     1924     * @param object $smarty Smarty object 
     1925     * @param object $net    Network object 
     1926     * 
     1927     * @return void 
     1928     * 
     1929     * @static 
     1930     * @access public 
     1931     */ 
     1932    public static function assignSmartyValues($smarty, $net = null) 
     1933    { 
     1934        if (!$net) { 
     1935            $net = Network::getCurrentNetwork(); 
     1936        } 
     1937 
     1938        // Set network details 
    15961939        $smarty->assign('networkName', $net ? $net->getName() : ''); 
    15971940        $smarty->assign('networkHomepageURL', $net ? $net->getHomepageURL() : ''); 
     1941 
    15981942        // Set networks usage information 
    15991943        $smarty->assign('networkNumValidUsers', $net ? $net->getNumValidUsers() : 0); 
     
    16031947        $smarty->assign('networkNumDeployedNodes', $net ? $net->getNumDeployedNodes() : 0); 
    16041948        $smarty->assign('networkNumOnlineNodes', $net ? $net->getNumOnlineNodes() : 0); 
     1949        $smarty->assign('networkNumNonMonitoredNodes', $net ? $net->getNumOnlineNodes(true) : 0); 
    16051950    } 
    16061951} 
  • trunk/wifidog-auth/wifidog/classes/Node.php

    r1088 r1089  
    5151require_once('classes/DateTime.php'); 
    5252require_once('classes/InterfaceElements.php'); 
     53require_once('classes/MainUI.php'); 
    5354 
    5455/** 
     
    6869        private $id; 
    6970        private static $current_node_id = null; 
     71 
     72        /** 
     73         * List of deployment statuses 
     74         * 
     75         * @var array 
     76         * @access private 
     77         */ 
     78        private $_deploymentStatuses = array(); 
    7079 
    7180        /** 
     
    187196        } 
    188197 
    189         /** Create a new Node in the database 
    190          * @param $node_id The id to be given to the new node.  If not present, a 
    191          * guid will be assigned. 
    192          * @param $network Network object.  The node's network.  If not present, 
    193          * the current Network will be assigned 
    194          * 
    195          * @return the newly created Node object, or null if there was an error 
    196          */ 
    197         static function createNewObject($node_id = null, $network = null) 
    198         { 
    199                 global $db; 
    200                 if (empty ($node_id)) 
    201                 { 
     198        /** 
     199         * Create a new Node in the database 
     200         * 
     201         * @param string $node_id The Id to be given to the new node.  If not 
     202         *                        present, guid will be assigned. 
     203         * @param object $network Network object.  The node's network.  If not 
     204         *                        present, the current Network will be assigned 
     205         * 
     206         * @return mixed The newly created Node object, or null if there was 
     207         *               an error 
     208         * 
     209         * @static 
     210         * @access public 
     211         */ 
     212        public static function createNewObject($node_id = null, $network = null) 
     213        { 
     214            // Define globals 
     215                global $db; 
     216 
     217                if (empty ($node_id)) { 
    202218                        $node_id = get_guid(); 
    203219                } 
     220 
    204221                $node_id = $db->escapeString($node_id); 
    205222 
    206                 if (empty ($network)) 
    207                 { 
    208                         $network = Network :: getCurrentNetwork(); 
    209                 } 
     223                if (empty ($network)) { 
     224                        $network = Network::getCurrentNetwork(); 
     225                } 
     226 
    210227                $network_id = $db->escapeString($network->getId()); 
    211228 
    212229                $node_deployment_status = $db->escapeString("IN_PLANNING"); 
    213230                $node_name = _("New node"); 
    214                 if (Node :: nodeExists($node_id)) 
    215                         throw new Exception(_('This node already exists.')); 
    216  
    217                 $sql = "INSERT INTO nodes (node_id, network_id, creation_date, node_deployment_status, name) VALUES ('$node_id', '$network_id', NOW(),'$node_deployment_status', '$node_name')"; 
    218  
    219                 if (!$db->execSqlUpdate($sql, false)) 
    220                 { 
    221                         throw new Exception(_('Unable to insert new node into database!')); 
    222                 } 
    223                 $object = new self($node_id); 
    224                 return $object; 
     231 
     232                try { 
     233            if (Node::nodeExists($node_id)) { 
     234                throw new Exception(_('This node already exists.')); 
     235            } 
     236 
     237            $sql = "INSERT INTO nodes (node_id, network_id, creation_date, node_deployment_status, name) VALUES ('$node_id', '$network_id', NOW(),'$node_deployment_status', '$node_name')"; 
     238 
     239            if (!$db->execSqlUpdate($sql, false)) { 
     240                throw new Exception(_('Unable to insert new node into database!')); 
     241            } 
     242 
     243            $object = new self($node_id); 
     244 
     245            return $object; 
     246        } catch (Exception $e) { 
     247            $ui = new MainUI(); 
     248            $ui->setToolSection('ADMIN'); 
     249            $ui->displayError($e->getMessage(), false); 
     250            exit; 
     251        } 
    225252        } 
    226253 
     
    235262                $html = ''; 
    236263                $name = "{$user_prefix}"; 
     264 
     265        $_deploymentStatuses = array( 
     266            "DEPLOYED" => _("Deployed"), 
     267            "IN_PLANNING" => _("In planning"), 
     268            "IN_TESTING" => _("In testing"), 
     269            "NON_WIFIDOG_NODE" => _("Non-Wifidog node"), 
     270            "PERMANENTLY_CLOSED" => _("Permanently closed"), 
     271            "TEMPORARILY_CLOSED" => _("Temporarily closed") 
     272            ); 
     273 
    237274                $sql = "SELECT node_id, name, node_deployment_status, is_splash_only_node from nodes WHERE 1=1 $sql_additional_where ORDER BY lower(node_id)"; 
    238275                $node_rows = null; 
    239276                $db->execSql($sql, $node_rows, false); 
    240                 if ($node_rows != null) 
    241                 { 
     277 
     278                if ($node_rows != null) { 
    242279                        Utils :: natsort2d($node_rows, "node_id"); 
    243280                        if ($type_interface != "table") { 
     
    267304                                { 
    268305                                        $href = GENERIC_OBJECT_ADMIN_ABS_HREF."?object_id={$node_row['node_id']}&object_class=Node&action=edit"; 
    269                                         $html .= "\t\t\t\t<tr class='row' onclick=\"javascript:location.href='{$href}'\">\n\t\t\t\t\t<td>{$node_row['name']}<noscript>(<a href='{$href}'>edit</a>)</noscript></td>\n\t\t\t\t\t<td>{$node_row['node_id']}</td>\n\t\t\t\t\t<td>{$node_row['node_deployment_status']}</td>\n\t\t\t\t</tr>\n"; 
     306                                        $_deployStatusNode = $node_row['node_deployment_status']; 
     307                                        $html .= "\t\t\t\t<tr class='row' onclick=\"javascript:location.href='{$href}'\">\n\t\t\t\t\t<td>{$node_row['name']}<noscript>(<a href='{$href}'>edit</a>)</noscript></td>\n\t\t\t\t\t<td>{$node_row['node_id']}</td>\n\t\t\t\t\t<td>{$_deploymentStatuses[$_deployStatusNode]}</td>\n\t\t\t\t</tr>\n"; 
    270308                                } 
    271309                                $html .= "\t\t\t</tbody>\n\t\t</table>\n"; 
     
    317355        } 
    318356 
    319         /** Process the new object interface. 
    320          *  Will return the new object if the user has the credentials and the form was fully filled. 
     357        /** 
     358         * Process the new object interface. 
     359         * 
     360         * Will return the new object if the user has the credentials and the form was fully filled. 
    321361         * @return the node object or null if no new node was created. 
    322362         */ 
    323         static function processCreateNewObjectUI() 
    324         { 
     363        public static function processCreateNewObjectUI() 
     364        { 
     365            // Init values 
    325366                $retval = null; 
    326367                $name = "new_node_id"; 
    327                 if (!empty ($_REQUEST[$name])) 
    328                 { 
     368 
     369                if (!empty ($_REQUEST[$name])) { 
    329370                        $node_id = $_REQUEST[$name]; 
    330371                        $name = "new_node_network_id"; 
    331                         if (!empty ($_REQUEST[$name])) 
    332                         { 
    333                                 $network = Network :: getObject($_REQUEST[$name]); 
     372 
     373                        if (!empty ($_REQUEST[$name])) { 
     374                                $network = Network::getObject($_REQUEST[$name]); 
     375                        } else { 
     376                                $network = Network::processSelectNetworkUI('new_node'); 
    334377                        } 
    335                         else 
    336                         { 
    337                                 $network = Network :: processSelectNetworkUI('new_node'); 
     378 
     379                        if ($node_id && $network) { 
     380                            try { 
     381                                if (!$network->hasAdminAccess(User :: getCurrentUser())) { 
     382                                        throw new Exception(_("Access denied")); 
     383                                } 
     384                } catch (Exception $e) { 
     385                    $ui = new MainUI(); 
     386                    $ui->setToolSection('ADMIN'); 
     387                    $ui->displayError($e->getMessage(), false); 
     388                    exit; 
     389                } 
     390 
     391                                $retval = self::createNewObject($node_id, $network); 
    338392                        } 
    339                         if ($node_id && $network) 
    340                         { 
    341                                 if (!$network->hasAdminAccess(User :: getCurrentUser())) 
    342                                 { 
    343                                         throw new Exception(_("Access denied")); 
    344                                 } 
    345                                 $retval = self :: createNewObject($node_id, $network); 
    346                         } 
    347                 } 
     393                } 
     394 
    348395                return $retval; 
    349396        } 
     
    377424 
    378425                foreach ($status_list as $status) { 
    379                         $tab[] = array($status['node_deployment_status'], $status['node_deployment_status']); 
     426                    $_statusvalue = $status['node_deployment_status']; 
     427                        $tab[] = array($_statusvalue, $this->_deploymentStatuses["$_statusvalue"]); 
    380428                } 
    381429 
     
    385433        } 
    386434 
    387         /** Get the selected deployment status 
    388          * @param $user_prefix A identifier provided by the programmer to recognise it's generated form 
    389          * @return the deployment status 
     435        /** 
     436         * Get the selected deployment status 
     437         * 
     438         * @param string $user_prefix An identifier provided by the programmer to 
     439         *                            recognise it's generated form 
     440         * 
     441         * @return string The deployment status 
     442         * 
     443         * @access public 
    390444         */ 
    391445        public function processSelectDeploymentStatus($user_prefix) 
     
    410464                        throw new Exception(sprintf(_("The node %s could not be found in the database!"), $node_id_str)); 
    411465                } 
     466 
     467        $this->_deploymentStatuses = array( 
     468            "DEPLOYED" => _("Deployed"), 
     469            "IN_PLANNING" => _("In planning"), 
     470            "IN_TESTING" => _("In testing"), 
     471            "NON_WIFIDOG_NODE" => _("Non-Wifidog node"), 
     472            "PERMANENTLY_CLOSED" => _("Permanently closed"), 
     473            "TEMPORARILY_CLOSED" => _("Temporarily closed") 
     474            ); 
     475 
    412476                $this->mRow = $row; 
    413477                $this->id = $row['node_id']; 
     
    744808         * Retrieves the admin interface of this object 
    745809         * 
    746          * @return The HTML fragment for this interface 
     810         * @return string The HTML fragment for this interface 
    747811         * 
    748812         * @access public 
     
    756820                $html = ''; 
    757821 
    758                 if (!User::getCurrentUser()) { 
    759                         throw new Exception(_('Access denied!')); 
    760                 } 
     822                try { 
     823                if (!User::getCurrentUser()) { 
     824                        throw new Exception(_('Access denied!')); 
     825                } 
     826        } catch (Exception $e) { 
     827            $ui = new MainUI(); 
     828            $ui->setToolSection('ADMIN'); 
     829            $ui->displayError($e->getMessage(), false); 
     830            exit; 
     831        } 
    761832 
    762833                // Get information about the network 
     
    9961067        } 
    9971068 
    998         /** Process admin interface of this object. 
    999         */ 
     1069        /** 
     1070         * Process admin interface of this object. 
     1071         * 
     1072         * @return void 
     1073         * 
     1074         * @access public 
     1075         */ 
    10001076        public function processAdminUI() 
    10011077        { 
    1002                 $user = User :: getCurrentUser(); 
    1003  
    1004                 if (!$this->isOwner($user) && !$user->isSuperAdmin()) 
    1005                 { 
    1006                         throw new Exception(_('Access denied!')); 
    1007                 } 
     1078                $user = User::getCurrentUser(); 
     1079 
     1080                try { 
     1081                if (!$this->isOwner($user) && !$user->isSuperAdmin()) { 
     1082                        throw new Exception(_('Access denied!')); 
     1083                } 
     1084        } catch (Exception $e) { 
     1085            $ui = new MainUI(); 
     1086            $ui->setToolSection('ADMIN'); 
     1087            $ui->displayError($e->getMessage(), false); 
     1088            exit; 
     1089        } 
    10081090 
    10091091                // Check if user is a admin 
     
    12881370        } 
    12891371 
    1290         /** The list of users online at this node 
    1291          * @return An array of User object, or en empty array */ 
    1292         function getOnlineUsers() 
    1293         { 
    1294                 global $db; 
    1295                 $retval = array (); 
     1372        /** 
     1373         * The list of users online at this node 
     1374         * 
     1375         * @return array An array of User object, or an empty array 
     1376         * 
     1377         * @access public 
     1378         */ 
     1379        public function getOnlineUsers() 
     1380        { 
     1381            // Define globals 
     1382                global $db; 
     1383 
     1384                // Init values 
     1385                $retval = array(); 
    12961386                $users = null; 
     1387                $anonUsers = 0; 
     1388 
    12971389                $db->execSql("SELECT users.user_id FROM users,connections WHERE connections.token_status='".TOKEN_INUSE."' AND users.user_id=connections.user_id AND connections.node_id='{$this->id}'", $users, false); 
    1298                 if ($users != null) 
    1299                 { 
    1300                         foreach ($users as $user_row) 
    1301                         { 
    1302                                 $retval[] = User :: getObject($user_row['user_id']); 
     1390 
     1391                if ($users != null) { 
     1392                        foreach ($users as $user_row) { 
     1393                            if ($this->isConfiguredSplashOnly()) { 
     1394                                if (User::getObject($user_row['user_id']) == "SPLASH_ONLY_USER") { 
     1395                                    $anonUsers++; 
     1396                                } else { 
     1397                                        $retval[] = User::getObject($user_row['user_id']); 
     1398                                } 
     1399                            } else { 
     1400                                    $retval[] = User::getObject($user_row['user_id']); 
     1401                            } 
    13031402                        } 
    1304                 } 
     1403 
     1404                    if ($this->isConfiguredSplashOnly() && $anonUsers == 1) { 
     1405                            $retval[] = "One anonymous user"; 
     1406                    } else if ($this->isConfiguredSplashOnly() && $anonUsers > 1) { 
     1407                            $retval[] = sprintf("%d anonymous users", $anonUsers); 
     1408                    } 
     1409                } 
     1410 
    13051411                return $retval; 
    13061412        } 
    13071413 
    1308         /** Find out how many users are online this specific Node 
    1309          * @return Number of online users 
    1310          */ 
    1311         function getNumOnlineUsers() 
    1312         { 
    1313                 global $db; 
     1414        /** 
     1415         * Find out how many users are online this specific Node 
     1416         * 
     1417         * @return int Number of online users 
     1418         * 
     1419         * @access public 
     1420         */ 
     1421        public function getNumOnlineUsers() 
     1422        { 
     1423            // Define globals 
     1424                global $db; 
     1425 
     1426                // Init values 
    13141427                $retval = array (); 
    13151428                $row = null; 
    1316                 if(!$this->isConfiguredSplashOnly()) 
     1429 
     1430                if (!$this->isConfiguredSplashOnly()) { 
    13171431                        $db->execSqlUniqueRes("SELECT COUNT(DISTINCT users.user_id) as count FROM users,connections WHERE connections.token_status='".TOKEN_INUSE."' AND users.user_id=connections.user_id AND connections.node_id='{$this->id}'", $row, false); 
    1318                 else 
     1432                } else { 
    13191433                        $db->execSqlUniqueRes("SELECT COUNT(DISTINCT connections.user_mac) as count FROM connections WHERE connections.token_status='".TOKEN_INUSE."' AND connections.node_id='{$this->id}'", $row, false); 
     1434                } 
     1435 
    13201436                return $row['count']; 
    13211437        } 
  • trunk/wifidog-auth/wifidog/classes/Server.php

    r1085 r1089  
    403403 
    404404                        if ($_serverId) { 
    405                                 if (!User::getCurrentUser()->isSuperAdmin()) { 
    406                                         throw new Exception(_("Access denied")); 
    407                                 } 
     405                            try { 
     406                                if (!User::getCurrentUser()->isSuperAdmin()) { 
     407                                        throw new Exception(_("Access denied")); 
     408                                } 
     409                } catch (Exception $e) { 
     410                    require_once('classes/MainUI.php'); 
     411 
     412                    $ui = new MainUI(); 
     413                    $ui->setToolSection('ADMIN'); 
     414                    $ui->displayError($e->getMessage(), false); 
     415                    exit; 
     416                } 
    408417 
    409418                                $_retVal = self::createNewObject($_serverId); 
     
    780789        { 
    781790        require_once('classes/User.php'); 
    782                 if (!User::getCurrentUser()->isSuperAdmin()) { 
    783                         throw new Exception(_('Access denied!')); 
    784                 } 
     791 
     792        try { 
     793                if (!User::getCurrentUser()->isSuperAdmin()) { 
     794                        throw new Exception(_('Access denied!')); 
     795                } 
     796        } catch (Exception $e) { 
     797            $ui = new MainUI(); 
     798            $ui->setToolSection('ADMIN'); 
     799            $ui->displayError($e->getMessage(), false); 
     800            exit; 
     801        } 
    785802 
    786803                // creation_date 
     
    877894 * End: 
    878895 */ 
    879  
  • trunk/wifidog-auth/wifidog/classes/Statistics.php

    r1088 r1089  
    4747 */ 
    4848require_once('include/common.php'); 
     49require_once('classes/MainUI.php'); 
    4950 
    5051/** 
     
    378379     * 
    379380     * @return string HTML markup 
     381     * 
     382     * @access private 
    380383     */ 
    381384    private function getSelectedNodesUI() 
    382385    { 
     386        // Define globals 
    383387        global $db; 
     388 
     389        // Init values 
    384390        $html = ''; 
     391 
    385392        $name = "statistics_selected_nodes[]"; 
    386         $user = User :: getCurrentUser(); 
    387         if ($user->isSuperAdmin()) 
    388         { 
    389             $sql_join = ''; 
    390         } 
    391         else 
    392         { 
    393             $user_id = $db->escapeString($user->getId()); 
    394             $sql_join = " JOIN node_stakeholders ON (nodes.node_id=node_stakeholders.node_id AND user_id='$user_id') "; 
    395         } 
    396         $sql = "SELECT nodes.node_id, nodes.name from nodes $sql_join WHERE 1=1 ORDER BY lower(node_id)"; 
    397         $node_rows = null; 
    398         $db->execSql($sql, $node_rows, false); 
    399         $html .= "<select multiple size = 6 name='$name'>\n"; 
    400  
    401         /*count($this->report_selected_nodes)==0?$selected=' SELECTED ':$selected=''; 
    402                     $html.= "<option value='' $selected>"._("Statistics for all nodes")."</option>\n"; 
    403         */ 
    404         if ($node_rows != null) 
    405         { 
    406             foreach ($node_rows as $node_row) 
    407             { 
    408                 $html .= "<option "; 
    409                 if (array_key_exists($node_row['node_id'], $this->report_selected_nodes)) 
    410                 { 
    411                     $html .= " SELECTED "; 
     393        $user = User::getCurrentUser(); 
     394 
     395        try { 
     396            if (!isset($user)) { 
     397                throw new Exception(_('Access denied!')); 
     398            } else if ((!$user->isSuperAdmin() && !$user->isOwner()) || $user->isNobody()) { 
     399                throw new Exception(_('Access denied!')); 
     400            } 
     401 
     402            if ($user->isSuperAdmin()) { 
     403                $sql_join = ''; 
     404            } else { 
     405                $user_id = $db->escapeString($user->getId()); 
     406                $sql_join = " JOIN node_stakeholders ON (nodes.node_id=node_stakeholders.node_id AND user_id='$user_id') "; 
     407            } 
     408 
     409            $sql = "SELECT nodes.node_id, nodes.name from nodes $sql_join WHERE 1=1 ORDER BY lower(node_id)"; 
     410            $node_rows = null; 
     411            $db->execSql($sql, $node_rows, false); 
     412            $html .= "<select multiple size = 6 name='$name'>\n"; 
     413 
     414            if ($node_rows != null) { 
     415                foreach ($node_rows as $node_row) { 
     416                    $html .= "<option "; 
     417 
     418                    if (array_key_exists($node_row['node_id'], $this->report_selected_nodes)) { 
     419                        $html .= " SELECTED "; 
     420                    } 
     421 
     422                    $nom = $node_row['node_id'].": ".$node_row['name']; 
     423                    $nom = htmlspecialchars($nom, ENT_QUOTES, 'UTF-8'); 
     424                    $primary_key = htmlentities($node_row['node_id'], ENT_QUOTES, 'UTF-8'); 
     425                    $html .= "value='$primary_key'>$nom</option>\n"; 
    412426                } 
    413  
    414                 $nom = $node_row['node_id'].": ".$node_row['name']; 
    415                 $nom = htmlspecialchars($nom, ENT_QUOTES, 'UTF-8'); 
    416                 $primary_key = htmlentities($node_row['node_id'], ENT_QUOTES, 'UTF-8'); 
    417                 $html .= "value='$primary_key'>$nom</option>\n"; 
    418             } 
    419         } 
    420         $html .= "</select>\n"; 
     427            } 
     428 
     429            $html .= "</select>\n"; 
     430        } catch (Exception $e) { 
     431            $ui = new MainUI(); 
     432            $ui->setToolSection('ADMIN'); 
     433            $ui->displayError($e->getMessage(), false); 
     434            exit; 
     435        } 
     436 
    421437        return $html; 
    422438    } 
  • trunk/wifidog-auth/wifidog/node_list.php

    r1088 r1089  
    107107    throw new Exception(_("No nodes could not be found in the database")); 
    108108 
     109$deploymentStatuses = array( 
     110    "DEPLOYED" => _("Deployed"), 
     111    "IN_PLANNING" => _("In planning"), 
     112    "IN_TESTING" => _("In testing"), 
     113    "NON_WIFIDOG_NODE" => _("Non-Wifidog node"), 
     114    "PERMANENTLY_CLOSED" => _("Permanently closed"), 
     115    "TEMPORARILY_CLOSED" => _("Temporarily closed") 
     116    ); 
     117 
    109118$nodes_list = array (); 
    110119foreach ($nodes_results as $node_row) 
     
    113122    $node_row['duration'] = $db->GetDurationArrayFromIntervalStr($node_row['since_last_heartbeat']); 
    114123    $node_row['num_online_users'] = $node->getNumOnlineUsers(); 
     124    $nodeDeploymentStatus = $node_row['node_deployment_status']; 
     125    $node_row['node_deployment_status'] = $deploymentStatuses["$nodeDeploymentStatus"]; 
    115126    $nodes_list[] = $node_row; 
    116127} 
  • trunk/wifidog-auth/wifidog/templates/sites/index.tpl

    r1088 r1089  
    9393            {"%d hotspots are currently operationnal."|_|sprintf:$networkNumOnlineNodes} 
    9494        {/if} 
     95 
     96        {if $networkNumNonMonitoredNodes > 0} 
     97            {if $networkNumNonMonitoredNodes == 1} 
     98                {"Because of one hotspot not being monitored we don't know if it is currently operationnal."|_} 
     99            {else} 
     100                {"Because of %d hotspots not being monitored we don't know if they are currently operationnal."|_|sprintf:$networkNumNonMonitoredNodes} 
     101            {/if} 
     102        {/if} 
    95103    </p> 
    96104