Changeset 742

Show
Ignore:
Timestamp:
09/10/05 20:05:18 (8 years ago)
Author:
benoitg
Message:

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

  • Add UI to add a new Network
  • Improve UI to add a new Node and new Content
Location:
trunk/wifidog-auth
Files:
10 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/ChangeLog

    r741 r742  
     12005-09-10 Benoit Grégoire  <bock@step.polymtl.ca> 
     2        * Add UI to add a new Network 
     3        * Improve UI to add a new Node and new Content 
     4 
    152005-09-10 Philippe April  <philippe@ilesansfil.org> 
    26        * signup.php: Fixed bug in detecting is the user is already part of the 
  • trunk/wifidog-auth/wifidog/admin/content_admin.php

    r737 r742  
    3434$html .= '<form action="'.GENERIC_OBJECT_ADMIN_ABS_HREF.'" method="get">'; 
    3535$html .= "<input type=submit name='new_submit' value='"._("Add new content")."'>\n"; 
    36 $html .= "<input type='hidden' name='action' value='new'>\n"; 
     36$html .= "<input type='hidden' name='action' value='new_ui'>\n"; 
    3737$html .= "<input type='hidden' name='object_class' value='Content'>\n"; 
    3838$html .= '</form>'; 
  • trunk/wifidog-auth/wifidog/admin/generic_object_admin.php

    r734 r742  
    2121/**@file generic_object_admin.php 
    2222 * A simple interface to edit any object that implements the GenericObject interface.  The php file takes the following params: 
    23  * $_REQUEST['action']: new, edit, delete, preview (also save, but not meant for calling from outside this file) 
    24  * $_REQUEST['object_id']:  The id of the object ot be edited 
    25  * $_REQUEST['object_class']:  The class name of the object ot be edited 
    26  * $_REQUEST['node_id']: In preview mode, the current node to simulate display 
    27  * $_REQUEST['debug']:  If present and non empty, the $_REQUEST variables will be displayed 
     23 * $_REQUEST['action']: new, edit, delete, preview, process_new_ui, new_ui (also 
     24 * save, but not meant for calling from outside this file) $_REQUEST 
     25 * ['object_id']: The id of the object ot be edited $_REQUEST['object_class']: 
     26 * The class name of the object ot be edited $_REQUEST['node_id']: In preview 
     27 * mode, the current node to simulate display $_REQUEST['debug']:  If present 
     28 * and non empty, the $_REQUEST variables will be displayed 
    2829 * @author Copyright (C) 2005 Benoit Grégoire <bock@step.polymtl.ca>, 
    2930 * Technologies Coeus inc. 
     
    5051        $object = call_user_func(array ($class, 'createNewObject')); 
    5152        $_REQUEST['action'] = 'edit'; 
    52 } else { 
    53         if (empty ($_REQUEST['object_id'])) { 
    54                 echo "<div class='errormsg'>"._("Sorry, the 'object_id' parameter must be specified")."</div>\n"; 
     53} 
     54else if ($_REQUEST['action'] == 'process_new_ui') { 
     55        $object = call_user_func(array ($class, 'processCreateNewObjectUI')); 
     56                if (!$object) { 
     57                echo "<div class='errormsg'>"._("Sorry, the object couldn't be created.  You probably didn't fill the form properly")."</div>\n"; 
    5558                exit; 
    5659        } 
     60        $_REQUEST['action'] = 'edit'; 
     61} 
     62else if ($_REQUEST['action'] == 'new_ui') { 
     63        //No need for an object 
     64} 
     65 else { 
    5766        $object = call_user_func(array ($class, 'getObject'), $_REQUEST['object_id']); 
    5867} 
    5968 
    6069if ($_REQUEST['action'] == 'save') { 
    61         $html .= $object->processAdminUI(); 
    62         $object = call_user_func(array ($class, 'getObject'), $_REQUEST['object_id']); 
     70        $object->processAdminUI(); 
     71        //$object = call_user_func(array ($class, 'getObject'), $_REQUEST['object_id']); 
    6372        $_REQUEST['action'] = 'edit'; 
    6473} 
     
    7483        } 
    7584} 
     85if ($_REQUEST['action'] == 'new_ui') { 
     86                 
     87                $html .= "<form action='".GENERIC_OBJECT_ADMIN_ABS_HREF."' method='post'>"; 
     88        $html .= "<input type='hidden' name='object_class' value='".$class."'>\n"; 
     89                $html .= call_user_func(array ($class, 'getCreateNewObjectUI')); 
     90        $html .= "<input type='hidden' name='action' value='process_new_ui'>\n"; 
     91        $html .= "<input type=submit name='new_ui_submit' value='"._("Create")." ".$class."'>\n"; 
     92        $html .= '</form>'; 
     93         
    7694 
    77 if ($_REQUEST['action'] == 'edit') { 
     95} 
     96else if ($_REQUEST['action'] == 'edit') { 
     97                if (!$object) { 
     98                echo "<div class='errormsg'>"._("Sorry, the 'object_id' parameter must be specified")."</div>\n"; 
     99                exit; 
     100        } 
    78101        $common_input = ''; 
    79102        if (!empty ($_REQUEST['debug'])) { 
     
    102125        $html .= '</form>'; 
    103126} 
    104  
    105 if ($_REQUEST['action'] == 'preview') { 
     127else if ($_REQUEST['action'] == 'preview') { 
    106128        if (empty ($_REQUEST['node_id'])) { 
    107129                $node_id = null; 
  • trunk/wifidog-auth/wifidog/classes/Content.php

    r708 r742  
    7777                return $object; 
    7878        } 
     79         
     80                /** Get an interface to create a new object. 
     81        * @return html markup 
     82        */ 
     83        public static function getCreateNewObjectUI() 
     84        { 
     85                        $html =''; 
     86                        $html .= _("You must select a content type: "); 
     87                        $i = 0; 
     88                        foreach (self :: getAvailableContentTypes() as $classname) 
     89                        { 
     90                                $tab[$i][0] = $classname; 
     91                                $tab[$i][1] = $classname; 
     92                                $i ++; 
     93                        } 
     94                        $name = "new_content_content_type"; 
     95                        $default = 'TrivialLangstring'; 
     96                        $html .= FormSelectGenerator :: generateFromArray($tab, $default, $name, "Content", false); 
     97                 
     98                return $html; 
     99        } 
     100 
     101        /** Process the new object interface.  
     102         *  Will       return the new object if the user has the credentials 
     103         * necessary (Else an exception is thrown) and and the form was fully 
     104         * filled (Else the object returns null). 
     105         * @return the node object or null if no new node was created. 
     106         */ 
     107        static function processCreateNewObjectUI() 
     108{ 
     109        $retval = null; 
     110        $name = "new_content_content_type"; 
     111        $content_type = FormSelectGenerator :: getResult($name, "Content"); 
     112    if($content_type) 
     113    { 
     114        $retval = self::createNewObject($content_type); 
     115    } 
     116         
     117        return $retval; 
     118} 
     119         
    79120        /** Get the Content object, specific to it's content type  
    80121         * @param $content_id The content id 
  • trunk/wifidog-auth/wifidog/classes/GenericObject.php

    r705 r742  
    3737         */ 
    3838        static public function getObject($id); 
    39         /** Create a new Content object in the database  
     39        /** Create a new object in the database  
    4040         * @see GenericObject 
    4141         * @return the newly created object, or null if there was an error 
    4242         */ 
    4343        static function createNewObject(); 
     44 
     45        /** Get an interface to create a new object. 
     46        * @return html markup 
     47        */ 
     48        public static function getCreateNewObjectUI(); 
     49 
     50        /** Process the new object interface.  
     51         *  Will       return the new object if the user has the credentials 
     52         * necessary (Else an exception is thrown) and and the form was fully 
     53         * filled (Else the object returns null). 
     54         * @return the node object or null if no new node was created. 
     55         */ 
     56        static function processCreateNewObjectUI(); 
     57 
    4458 
    4559        /** Retreives the id of the object  
  • trunk/wifidog-auth/wifidog/classes/MainUI.php

    r736 r742  
    2525 */ 
    2626require_once BASEPATH.'include/common.php'; 
    27         /** @note We put a call to validate_schema() here so it systematically called 
    28  * from any UI page, but not from any machine readable pages  
    29  */  
    30                 require_once BASEPATH.'include/schema_validate.php'; 
    31                 validate_schema(); 
    32                  
     27/** @note We put a call to validate_schema() here so it systematically called 
     28* from any UI page, but not from any machine readable pages  
     29*/ 
     30require_once BASEPATH.'include/schema_validate.php'; 
     31validate_schema(); 
     32 
    3333if (CONF_USE_CRON_FOR_DB_CLEANUP == false) 
    3434{ 
     
    5555                $this->title = Network :: getCurrentNetwork()->getName().' '._("authentication server"); //Default title 
    5656        } 
    57          
     57 
    5858        /** Check if the tool section is enabled 
    5959         *  
     
    6363                return $this->tool_section_enabled; 
    6464        } 
    65          
     65 
    6666        public function setToolSectionEnabled($status) 
    6767        { 
     
    103103                                $html = ''; 
    104104 
    105                 if ($current_user && $current_user->isNobody()) 
    106                 { 
    107                     $html .= _("You do not have permissions to access any administration functions."); 
    108                 } else { 
    109  
    110                     $html .= "<ul class='admin_menu_list'>\n"; 
    111  
    112                     if ($current_user && $current_user->isSuperAdmin()) 
    113                     { 
    114                         $html .= "<li><a href='user_log.php'>"._("User logs")."</a></li>\n"; 
    115                         $html .= "<li><a href='online_users.php'>"._("Online Users")."</a></li>\n"; 
    116                         $html .= "<li><a href='stats.php'>"._("Statistics")."</a></li>\n"; 
    117                         $html .= "<li><a href='import_user_database.php'>"._("Import NoCat user database")."</a></li>\n"; 
    118                         $html .= "<li><a href='content_admin.php'>"._("Content manager")."</a></li>\n"; 
    119                     } 
    120  
    121                     $html .= "</ul>\n"; 
    122  
    123                     // If the user is super admin OR owner of at least one hotspot show the menu 
    124                     if ($current_user && ($current_user->isSuperAdmin() || $current_user->isOwner())) 
    125                     { 
    126                         /* Node admin */ 
    127                         $html .= "<div class='admin_section_container'>\n"; 
    128                         $html .= '<form action="'.GENERIC_OBJECT_ADMIN_ABS_HREF.'" method="post">'; 
    129                         $html .= "<div class='admin_section_title'>"._("Node administration:")." </div>\n"; 
    130  
    131                         $html .= "<div class='admin_section_data'>\n"; 
    132  
    133                         if ($current_user->isSuperAdmin()) 
    134                             $sql_additional_where = ''; 
    135                         else 
    136                             $sql_additional_where = "AND node_id IN (SELECT node_id from node_stakeholders WHERE is_owner = true AND user_id='".$current_user->getId()."')"; 
    137                         $html .= "<div id='NodeSelector'>\n"; 
    138                         $html .= Node :: getSelectNodeUI('object_id', $sql_additional_where); 
    139                         $html .= "</div>\n"; 
    140                         $html .= "</div>\n"; 
    141                         $html .= "<div class='admin_section_tools'>\n"; 
    142  
    143                         $html .= "<input type='hidden' name='object_class' value='Node'>\n"; 
    144                         $html .= "<input type='hidden' name='action' value='edit'>\n"; 
    145                         $html .= "<input type='submit' name='edit_submit' value='"._("Edit")."'>\n"; 
    146  
    147                         $html .= "</div>\n"; 
    148                         $html .= '</form>'; 
    149                         $html .= "</div>\n"; 
    150                     } 
    151  
    152                     /* Network admin */ 
    153                     if ($current_user && $current_user->isSuperAdmin()) 
    154                     { 
    155                         $html .= "<div class='admin_section_container'>\n"; 
    156                         $html .= '<form action="'.GENERIC_OBJECT_ADMIN_ABS_HREF.'" method="post">'; 
    157                         $html .= "<div class='admin_section_title'>"._("Network administration:")." </div>\n"; 
    158  
    159                         $html .= "<div class='admin_section_data'>\n"; 
    160                         $html .= "<input type='hidden' name='action' value='edit'>\n"; 
    161                         $html .= "<input type='hidden' name='object_class' value='Network'><br>\n"; 
    162                         $html .= Network :: getSelectNetworkUI('object_id'); 
    163                         $html .= "</div>\n"; 
    164                         $html .= "<div class='admin_section_tools'>\n"; 
    165  
    166                         $html .= "<input type=submit name='edit_submit' value='"._("Edit")."'>\n"; 
    167                         $html .= "</div>\n"; 
    168                         $html .= '</form>'; 
    169                         $html .= "</div>\n"; 
    170                     } 
    171                 } 
     105                                if ($current_user && $current_user->isNobody()) 
     106                                { 
     107                                        $html .= _("You do not have permissions to access any administration functions."); 
     108                                } 
     109                                else 
     110                                { 
     111 
     112                                        if ($current_user && $current_user->isSuperAdmin()) 
     113                                        { 
     114                                                $html .= "<li><a href='user_log.php'>"._("User logs")."</a></li>\n"; 
     115                                                $html .= "<li><a href='online_users.php'>"._("Online Users")."</a></li>\n"; 
     116                                                $html .= "<li><a href='stats.php'>"._("Statistics")."</a></li>\n"; 
     117                                                $html .= "<li><a href='import_user_database.php'>"._("Import NoCat user database")."</a></li>\n"; 
     118                                                $html .= "<li><a href='content_admin.php'>"._("Content manager")."</a></li>\n"; 
     119                                        } 
     120 
     121                                        $html .= "</ul>\n"; 
     122 
     123                                        // If the user is super admin OR owner of at least one hotspot show the menu 
     124                                        if ($current_user && ($current_user->isSuperAdmin() || $current_user->isOwner())) 
     125                                        { 
     126                                                /* Node admin */ 
     127                                                $html .= "<div class='admin_section_container'>\n"; 
     128                                                $html .= '<form action="'.GENERIC_OBJECT_ADMIN_ABS_HREF.'" method="post">'; 
     129                                                $html .= "<div class='admin_section_title'>"._("Node administration:")." </div>\n"; 
     130 
     131                                                $html .= "<div class='admin_section_data'>\n"; 
     132 
     133                                                if ($current_user->isSuperAdmin()) 
     134                                                        $sql_additional_where = ''; 
     135                                                else 
     136                                                        $sql_additional_where = "AND node_id IN (SELECT node_id from node_stakeholders WHERE is_owner = true AND user_id='".$current_user->getId()."')"; 
     137                                                $html .= "<div id='NodeSelector'>\n"; 
     138                                                $html .= Node :: getSelectNodeUI('object_id', $sql_additional_where); 
     139                                                $html .= "</div>\n"; 
     140                                                $html .= "</div>\n"; 
     141                                                $html .= "<div class='admin_section_tools'>\n"; 
     142 
     143                                                $html .= "<input type='hidden' name='object_class' value='Node'>\n"; 
     144                                                $html .= "<input type='hidden' name='action' value='edit'>\n"; 
     145                                                $html .= "<input type='submit' name='edit_submit' value='"._("Edit")."'>\n"; 
     146 
     147                                                $html .= "</div>\n"; 
     148                                                $html .= '</form>'; 
     149                                                $html .= "<div class='admin_section_tools'>\n"; 
     150                                                $html .= '<form action="'.GENERIC_OBJECT_ADMIN_ABS_HREF.'" method="post">'; 
     151                                                $html .= "<input type='hidden' name='action' value='new_ui'>\n"; 
     152                                                $html .= "<input type='hidden' name='object_class' value='Node'><br>\n"; 
     153                                                $html .= "<input type=submit name='new_submit' value='"._("Create")."'>\n"; 
     154                                                $html .= "</form>\n"; 
     155                                                $html .= "</div>\n"; 
     156                                                $html .= "</div>\n"; 
     157                                        } 
     158 
     159                                        /* Network admin */ 
     160                                        if ($current_user && $current_user->isSuperAdmin()) 
     161                                        { 
     162                                                $html .= "<div class='admin_section_container'>\n"; 
     163                                                $html .= '<form action="'.GENERIC_OBJECT_ADMIN_ABS_HREF.'" method="post">'; 
     164                                                $html .= "<div class='admin_section_title'>"._("Network administration:")." </div>\n"; 
     165 
     166                                                $html .= "<div class='admin_section_data'>\n"; 
     167                                                $html .= "<input type='hidden' name='action' value='edit'>\n"; 
     168                                                $html .= "<input type='hidden' name='object_class' value='Network'><br>\n"; 
     169                                                $html .= Network :: getSelectNetworkUI('object_id'); 
     170                                                $html .= "</div>\n"; 
     171                                                $html .= "<div class='admin_section_tools'>\n"; 
     172 
     173                                                $html .= "<input type=submit name='edit_submit' value='"._("Edit")."'>\n"; 
     174                                                $html .= "</div>\n"; 
     175                                                $html .= "</form>\n"; 
     176                                                $html .= "<div class='admin_section_tools'>\n"; 
     177                                                $html .= '<form action="'.GENERIC_OBJECT_ADMIN_ABS_HREF.'" method="post">'; 
     178                                                $html .= "<input type='hidden' name='action' value='new_ui'>\n"; 
     179                                                $html .= "<input type='hidden' name='object_class' value='Network'><br>\n"; 
     180                                                $html .= "<input type=submit name='new_submit' value='"._("Create")."'>\n"; 
     181                                                $html .= "</form>\n"; 
     182                                                $html .= "</div>\n"; 
     183                                                $html .= "</div>\n"; 
     184                                        } 
     185                                } 
    172186                                break; 
    173187                        default : 
     
    327341 
    328342                $html .= "<body>"."\n"; 
    329                 if(isset($_REQUEST['debug_request'])) 
     343                if (isset ($_REQUEST['debug_request'])) 
    330344                { 
    331345                        $html .= '<pre>'; 
    332                         $html .= print_r($_REQUEST,true); 
     346                        $html .= print_r($_REQUEST, true); 
    333347                        $html .= '</pre>'; 
    334348                } 
    335349                $html .= '<div class="outer_container">'."\n"; 
    336350 
    337                  
    338                 if($this->isToolSectionEnabled()) 
     351                if ($this->isToolSectionEnabled()) 
    339352                { 
    340353                        /**** Tools ******/ 
    341354                        $html .= $this->getToolContent(); 
    342                          
     355 
    343356                        /**** Main section ****/ 
    344357                        $html .= "<div id='main_section'>"."\n"; 
     
    367380        { 
    368381                $html = "<p>$errmsg</p>\n"; 
    369                 $email = Network::getCurrentNetwork()->getTechSupportEmail(); 
    370                 if(!empty($email)) 
    371                 { 
    372                 $html .= "<p>"._("Please get in touch with ")."<a href='{$email}'>{$email}</a></p>"; 
     382                $email = Network :: getCurrentNetwork()->getTechSupportEmail(); 
     383                if (!empty ($email)) 
     384                { 
     385                        $html .= "<p>"._("Please get in touch with ")."<a href='{$email}'>{$email}</a></p>"; 
    373386                } 
    374387                $this->setMainContent($html); 
     
    378391} //End class 
    379392?> 
     393 
  • trunk/wifidog-auth/wifidog/classes/Network.php

    r733 r742  
    11<?php 
     2 
    23 
    34/********************************************************************\ 
     
    7273        { 
    7374                $retval = null; 
    74                         global $db; 
    75                         $sql = "SELECT network_id FROM networks WHERE is_default_network=TRUE ORDER BY creation_date LIMIT 1"; 
    76                         $network_row = null; 
    77                         $db->ExecSqlUniqueRes($sql, $network_row, false); 
    78                         if ($network_row == null) 
    79                         { 
    80                                 throw new Exception(_("Network::getDefaultNetwork:  Fatal error: Unable to find the default network!")); 
    81                         } 
    82                         $retval = new self($network_row['network_id']); 
    83                 return $retval; 
    84         } 
    85          
     75                global $db; 
     76                $sql = "SELECT network_id FROM networks WHERE is_default_network=TRUE ORDER BY creation_date LIMIT 1"; 
     77                $network_row = null; 
     78                $db->ExecSqlUniqueRes($sql, $network_row, false); 
     79                if ($network_row == null) 
     80                { 
     81                        throw new Exception(_("Network::getDefaultNetwork:  Fatal error: Unable to find the default network!")); 
     82                } 
     83                $retval = new self($network_row['network_id']); 
     84                return $retval; 
     85        } 
     86 
    8687        /** Get the current network for which the portal is displayed or to which a user is physically connected. 
    8788         * @param $real_network_only NOT IMPLEMENTED YET true or false.  If true, 
     
    100101                else 
    101102                { 
    102                         $retval = Network::getDefaultNetwork(); 
     103                        $retval = Network :: getDefaultNetwork(); 
    103104                } 
    104105                return $retval; 
     
    107108        /** Create a new Content object in the database  
    108109         * @see GenericObject 
     110         * @param $network_id The network id of the new network.  If absent, will be 
     111         * assigned a guid. 
    109112         * @return the newly created object, or null if there was an error 
    110113         */ 
    111         static function createNewObject() 
    112         { 
    113                 return null; /* Unsupported */ 
     114        static function createNewObject($network_id = null) 
     115        { 
     116                global $db; 
     117                if(empty($network_id)) 
     118                { 
     119                        $network_id = get_guid(); 
     120                } 
     121                $network_id = $db->EscapeString($network_id); 
     122                 
     123                $sql = "INSERT INTO networks (network_id, network_authenticator_class) VALUES ('$network_id', 'AuthenticatorLocalUser')"; 
     124 
     125                if (!$db->ExecSqlUpdate($sql, false)) 
     126                { 
     127                        throw new Exception(_('Unable to insert the new network in the database!')); 
     128                } 
     129                $object = new self($network_id); 
     130                return $object; 
     131 
    114132        } 
    115133 
     
    172190        } 
    173191 
     192        /** Get an interface to create a new network. 
     193        * @return html markup 
     194        */ 
     195        public static function getCreateNewObjectUI() 
     196        { 
     197                $html = ''; 
     198                $html .= _("Create new network with id")." \n"; 
     199                $name = "new_network_id"; 
     200                $html .= "<input type='text' size='10' name='{$name}'>\n"; 
     201                return $html; 
     202 
     203        } 
     204 
     205        /** Process the new object interface.  
     206         *  Will return the new object if the user has the credentials and the form was fully filled. 
     207         * @return the Network object or null if no new Network was created. 
     208         */ 
     209        static function processCreateNewObjectUI() 
     210        { 
     211                $retval = null; 
     212                $name = "new_network_id"; 
     213                if (!empty ($_REQUEST[$name])) 
     214                { 
     215                        $network_id = $_REQUEST[$name]; 
     216                        if ($network_id) 
     217                        { 
     218                                if (!User :: getCurrentUser()->isSuperAdmin()) 
     219                                { 
     220                                        throw new Exception(_("Access denied")); 
     221                                } 
     222                                $retval = self :: createNewObject($network_id); 
     223                        } 
     224                } 
     225                return $retval; 
     226        } 
     227 
    174228        private function __construct($p_network_id) 
    175229        { 
     
    217271                return $retval; 
    218272        } 
    219          
     273 
    220274        /** 
    221     * Retrieves the network name  
     275        * Retrieves the network name  
    222276         * @return A string 
    223     */ 
     277        */ 
    224278        public function getName() 
    225279        { 
     
    230284         * @param $value The new value  
    231285         * @return true on success, false on failure 
    232     */ 
     286        */ 
    233287        function setName($value) 
    234288        { 
     
    245299 
    246300        /** 
    247     * Retrieves the network's creation date 
     301        * Retrieves the network's creation date 
    248302         * @return A string 
    249     */ 
     303        */ 
    250304        public function getCreationDate() 
    251305        { 
     
    298352                return $retval; 
    299353        } 
    300                  
     354 
    301355        /** Retreives the authenticator's parameters 
    302356         * @return A string */ 
     
    321375                return $retval; 
    322376        } 
    323          
     377 
    324378        /** Get the Authenticator object for this network  
     379         * @todo:  Reimplement this using the muich safer call_user_func_array 
     380         * instead of eval()  Benoitg 2005-09-10 
    325381         * @return a subclass of Authenticator */ 
    326382        public function getAuthenticator() 
     
    336392                return eval ($objstring); 
    337393        } 
    338                  
     394 
    339395        /** Is the network the default network? 
    340396         * @return true or false */ 
    341397        public function isDefaultNetwork() 
    342398        { 
    343                 ($this->mRow['is_default_network']=='t')?$retval=true:$retval=false; 
     399                ($this->mRow['is_default_network'] == 't') ? $retval = true : $retval = false; 
    344400                return $retval; 
    345401        } 
     
    383439                return $retval; 
    384440        } 
    385                          
     441 
    386442        /** Retreives the FROM adress of the validation email 
    387443         * @return A string */ 
     
    406462                return $retval; 
    407463        } 
    408                  
     464 
    409465        /** Can an account be connected more than once at the same time? 
    410466         * @return true or false */ 
     
    423479                { 
    424480                        global $db; 
    425                         $value?$value='TRUE':$value='FALSE'; 
     481                        $value ? $value = 'TRUE' : $value = 'FALSE'; 
    426482                        $retval = $db->ExecSqlUpdate("UPDATE networks SET allow_multiple_login = {$value} WHERE network_id = '{$this->getId()}'", false); 
    427483                        $this->refresh(); 
     
    434490        public function getSplashOnlyNodesAllowed() 
    435491        { 
    436                 return (($this->mRow['allow_splash_only_nodes']=='t') ? true : false); 
     492                return (($this->mRow['allow_splash_only_nodes'] == 't') ? true : false); 
    437493        } 
    438494 
     
    446502                { 
    447503                        global $db; 
    448                         $value?$value='TRUE':$value='FALSE'; 
     504                        $value ? $value = 'TRUE' : $value = 'FALSE'; 
    449505                        $retval = $db->ExecSqlUpdate("UPDATE networks SET allow_splash_only_nodes = {$value} WHERE network_id = '{$this->getId()}'", false); 
    450506                        $this->refresh(); 
    451507                } 
    452508                return $retval; 
    453         }                
    454          
    455                 /** 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. 
    456          * @param $username The username of the user 
    457          * @param $account_origin The account origin 
    458          * @return a User object 
    459          */ 
     509        } 
     510 
     511        /** 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. 
     512        * @param $username The username of the user 
     513        * @param $account_origin The account origin 
     514        * @return a User object 
     515        */ 
    460516        public function getSplashOnlyUser() 
    461517        { 
    462518                $username = 'SPLASH_ONLY_USER'; 
    463519 
    464                 $user = User::getUserByUsernameAndOrigin($username, $this); 
    465                 if(!$user) 
    466                 { 
    467                         $user = User::createUser(get_guid(), $username, $this, '', ''); 
    468                         $user->setAccountStatus(ACCOUNT_STATUS_ALLOWED);         
    469                 }        
     520                $user = User :: getUserByUsernameAndOrigin($username, $this); 
     521                if (!$user) 
     522                { 
     523                        $user = User :: createUser(get_guid(), $username, $this, '', ''); 
     524                        $user->setAccountStatus(ACCOUNT_STATUS_ALLOWED); 
     525                } 
    470526                return $user; 
    471527        } 
     
    474530        public function getCustomPortalRedirectAllowed() 
    475531        { 
    476                 return (($this->mRow['allow_custom_portal_redirect']=='t') ? true : false); 
     532                return (($this->mRow['allow_custom_portal_redirect'] == 't') ? true : false); 
    477533        } 
    478534 
     
    486542                { 
    487543                        global $db; 
    488                         $value?$value='TRUE':$value='FALSE'; 
     544                        $value ? $value = 'TRUE' : $value = 'FALSE'; 
    489545                        $retval = $db->ExecSqlUpdate("UPDATE networks SET allow_custom_portal_redirect = {$value} WHERE network_id = '{$this->getId()}'", false); 
    490546                        $this->refresh(); 
    491547                } 
    492548                return $retval; 
    493         }                
     549        } 
     550 
     551        /** Does the user have admin access to this network?  
     552         * @return true our false*/ 
     553        function hasAdminAccess(User $user) 
     554        { 
     555                global $db; 
     556                $retval = false; 
     557                if ($user != null) 
     558                { 
     559                        $user_id = $user->getId(); 
     560                        $retval = false; 
     561                        $db->ExecSqlUniqueRes("SELECT * FROM network_stakeholders WHERE is_admin = true AND network_id='{$this->id}' AND user_id='{$user_id}'", $row, false); 
     562                        if ($row != null) 
     563                        { 
     564                                $retval = true; 
     565                        } 
     566                        else 
     567                                if ($user->isSuperAdmin()) 
     568                                { 
     569                                        $retval = true; 
     570                                } 
     571                } 
     572                return $retval; 
     573        } 
    494574 
    495575        /**Get an array of all Content linked to the network 
     
    538618                $html .= "</div>\n"; 
    539619                $html .= "</div>\n"; 
    540                  
     620 
    541621                // name 
    542622                $html .= "<div class='admin_section_container'>\n"; 
     
    569649                $html .= "</div>\n"; 
    570650 
    571  
    572651                //  network_authenticator_class 
    573652                $html .= "<div class='admin_section_container'>\n"; 
     
    588667                $html .= "<input type='text' size ='50' value='$value' name='$name'>\n"; 
    589668                $html .= "</div>\n"; 
    590                 $html .= "</div>\n";             
    591                  
     669                $html .= "</div>\n"; 
     670 
    592671                //  is_default_network 
    593672                $html .= "<div class='admin_section_container'>\n"; 
     
    595674                $html .= "<div class='admin_section_data'>\n"; 
    596675                $name = "network_".$this->getId()."_is_default_network"; 
    597                 $this->isDefaultNetwork()? $checked='CHECKED': $checked=''; 
     676                $this->isDefaultNetwork() ? $checked = 'CHECKED' : $checked = ''; 
    598677                $html .= "<input type='checkbox' name='$name' $checked>\n"; 
    599678                $html .= "</div>\n"; 
    600                 $html .= "</div>\n";                     
    601          
     679                $html .= "</div>\n"; 
     680 
    602681                //  validation_grace_time 
    603682                $html .= "<div class='admin_section_container'>\n"; 
     
    609688                $html .= "</div>\n"; 
    610689                $html .= "</div>\n"; 
    611                          
     690 
    612691                //  validation_email_from_address 
    613692                $html .= "<div class='admin_section_container'>\n"; 
     
    619698                $html .= "</div>\n"; 
    620699                $html .= "</div>\n"; 
    621                  
     700 
    622701                //  allow_multiple_login 
    623702                $html .= "<div class='admin_section_container'>\n"; 
     
    625704                $html .= "<div class='admin_section_data'>\n"; 
    626705                $name = "network_".$this->getId()."_allow_multiple_login"; 
    627                 $this->getMultipleLoginAllowed()? $checked='CHECKED': $checked=''; 
     706                $this->getMultipleLoginAllowed() ? $checked = 'CHECKED' : $checked = ''; 
    628707                $html .= "<input type='checkbox' name='$name' $checked>\n"; 
    629708                $html .= "</div>\n"; 
    630709                $html .= "</div>\n"; 
    631                  
     710 
    632711                //  allow_splash_only_nodes 
    633712                $html .= "<div class='admin_section_container'>\n"; 
     
    635714                $html .= "<div class='admin_section_data'>\n"; 
    636715                $name = "network_".$this->getId()."_allow_splash_only_nodes"; 
    637                 $this->getSplashOnlyNodesAllowed()? $checked='CHECKED': $checked=''; 
     716                $this->getSplashOnlyNodesAllowed() ? $checked = 'CHECKED' : $checked = ''; 
    638717                $html .= "<input type='checkbox' name='$name' $checked>\n"; 
    639718                $html .= "</div>\n"; 
    640719                $html .= "</div>\n"; 
    641                  
     720 
    642721                //  allow_custom_portal_redirect 
    643722                $html .= "<div class='admin_section_container'>\n"; 
     
    645724                $html .= "<div class='admin_section_data'>\n"; 
    646725                $name = "network_".$this->getId()."_allow_custom_portal_redirect"; 
    647                 $this->getCustomPortalRedirectAllowed()? $checked='CHECKED': $checked=''; 
     726                $this->getCustomPortalRedirectAllowed() ? $checked = 'CHECKED' : $checked = ''; 
    648727                $html .= "<input type='checkbox' name='$name' $checked>\n"; 
    649728                $html .= "</div>\n"; 
    650729                $html .= "</div>\n"; 
    651                  
     730 
    652731                //      network_stakeholders 
    653732                $html .= "<div class='admin_section_container'>\n"; 
     
    659738                $html .= "WRITEME!"; 
    660739                $html .= "</div>\n"; 
    661                 $html .= "</div>\n";             
    662                                  
     740                $html .= "</div>\n"; 
     741 
    663742                // Create new nodes 
    664743                $html .= "<div class='admin_section_container'>\n"; 
     
    666745 
    667746                $html .= "<div class='admin_section_data'>\n"; 
    668                 $name = "network_{$this->getId()}_new_node_id"; 
    669                 $html .= "<input type='text' size='10' name='{$name}'>\n"; 
     747 
     748                $html .= Node :: getCreateNewObjectUI($this); 
    670749 
    671750                $html .= "<div class='admin_section_tools'>\n"; 
     
    714793                //pretty_print_r($_REQUEST); 
    715794                $user = User :: getCurrentUser(); 
    716                 if (!$user->isSuperAdmin()) 
     795                if (!$this->hasAdminAccess($user)) 
    717796                { 
    718797                        throw new Exception(_('Access denied!')); 
     
    722801                $name = "network_".$this->getId()."_name"; 
    723802                $this->setName($_REQUEST[$name]); 
    724                  
     803 
    725804                // homepage_url 
    726805                $name = "network_".$this->getId()."_homepage_url"; 
    727806                $this->setHomepageURL($_REQUEST[$name]); 
    728807 
    729  
    730808                // tech_support_email 
    731809                $name = "network_".$this->getId()."_tech_support_email"; 
     
    739817                $name = "network_".$this->getId()."_network_authenticator_params"; 
    740818                $this->setAuthenticatorConstructorParams($_REQUEST[$name]); 
    741                  
     819 
    742820                //  is_default_network 
    743821                $name = "network_".$this->getId()."_is_default_network"; 
    744                 if($_REQUEST[$name]=='on') 
     822                if ($_REQUEST[$name] == 'on') 
    745823                        $this->setAsDefaultNetwork(); 
    746          
     824 
    747825                //  validation_grace_time 
    748826                $name = "network_".$this->getId()."_validation_grace_time"; 
    749827                $this->setValidationGraceTime($_REQUEST[$name]); 
    750                          
     828 
    751829                //  validation_email_from_address 
    752830                $name = "network_".$this->getId()."_validation_email_from_address"; 
    753                 $this->setValidationEmailFromAddress($_REQUEST[$name]);  
    754                  
     831                $this->setValidationEmailFromAddress($_REQUEST[$name]); 
     832 
    755833                //  allow_multiple_login 
    756834                $name = "network_".$this->getId()."_allow_multiple_login"; 
    757                 $this->setMultipleLoginAllowed(empty($_REQUEST[$name])?false:true);      
    758                  
     835                $this->setMultipleLoginAllowed(empty ($_REQUEST[$name]) ? false : true); 
     836 
    759837                //  allow_splash_only_nodes 
    760838                $name = "network_".$this->getId()."_allow_splash_only_nodes"; 
    761                 $this->setSplashOnlyNodesAllowed(empty($_REQUEST[$name])?false:true);    
     839                $this->setSplashOnlyNodesAllowed(empty ($_REQUEST[$name]) ? false : true); 
    762840 
    763841                //  allow_custom_portal_redirect 
    764842                $name = "network_".$this->getId()."_allow_custom_portal_redirect"; 
    765                 $this->setCustomPortalRedirectAllowed(empty($_REQUEST[$name])?false:true);       
    766                                  
     843                $this->setCustomPortalRedirectAllowed(empty ($_REQUEST[$name]) ? false : true); 
     844 
    767845                // Node creation 
    768                 $create_new_node = "network_{$this->getId()}_create_node"; 
    769                 $new_node_id = "network_{$this->getId()}_new_node_id"; 
    770                 if (!empty ($_REQUEST[$create_new_node])) 
    771                         if (!empty ($_REQUEST[$new_node_id])) 
    772                         { 
    773                                 Node :: createNewNode($_REQUEST[$new_node_id], $this); 
    774                                 $url = GENERIC_OBJECT_ADMIN_ABS_HREF."?".http_build_query(array ("object_class" => "Node", "action" => "edit", "object_id" => $_REQUEST[$new_node_id])); 
    775                                 header("Location: {$url}"); 
    776                         } 
    777                         else 
    778                                 echo _("You MUST enter a node ID."); 
    779  
     846                $new_node = Node :: processCreateNewObjectUI(); 
     847                if ($new_node) 
     848                { 
     849                        $url = GENERIC_OBJECT_ADMIN_ABS_HREF."?".http_build_query(array ("object_class" => "Node", "action" => "edit", "object_id" => $new_node->getId())); 
     850                        header("Location: {$url}"); 
     851                } 
    780852                // Content management 
    781853                foreach ($this->getAllContent() as $content) 
     
    821893        public function delete(& $errmsg) 
    822894        { 
    823                 $errmsg = _("Network::delete() not supported"); 
    824                 return false; 
    825         } 
    826  
     895                $retval = false; 
     896                $user = User :: getCurrentUser(); 
     897                if (!$user->isSuperAdmin()) 
     898                { 
     899                        $errmsg = _('Access denied (must have super admin access)'); 
     900                } 
     901                else 
     902                { 
     903                global $db; 
     904                $id = $db->EscapeString($this->getId()); 
     905                if (!$db->ExecSqlUpdate("DELETE FROM networks WHERE network_id='{$id}'", false)) 
     906                { 
     907                        $errmsg = _('Could not delete network!'); 
     908                } 
     909                else 
     910                { 
     911                        $retval = true; 
     912                } 
     913                } 
     914                return $retval; 
     915        } 
    827916        /** Reloads the object from the database.  Should normally be called after a set operation */ 
    828917        protected function refresh() 
     
    833922} //End class 
    834923?> 
     924 
  • trunk/wifidog-auth/wifidog/classes/Node.php

    r733 r742  
    11<?php 
     2 
     3 
    24/********************************************************************\ 
    35 * This program is free software; you can redistribute it and/or    * 
     
    128130                $user = User :: getCurrentUser(); 
    129131                if ($this->isOwner($user) || $user->isSuperAdmin()) 
    130                 { 
    131                         $errmsg = _('Access denied!'); 
    132                 } 
    133  
     132{ 
    134133                global $db; 
    135134                $id = $db->EscapeString($this->getId()); 
     
    142141                        $retval = true; 
    143142                } 
     143} 
     144else 
     145                { 
     146                        $errmsg = _('Access denied!'); 
     147                } 
    144148 
    145149                return $retval; 
    146150        } 
    147151 
    148         /** Create a new Node in the database 
    149          * @param $id The id to be given to the new node 
     152        /** Create a new Node in the database  
     153         * @param $node_id The id to be given to the new node.  If not present, a 
     154         * guid will be assigned. 
     155         * @param $network Network object.  The node's network.  If not present, 
     156         * the current Network will be assigned 
     157         *  
    150158         * @return the newly created Node object, or null if there was an error 
    151159         */ 
    152         static function createNewObject() 
    153         { 
    154                 global $db; 
    155  
    156                 $node_id = $db->EscapeString(get_guid()); 
    157                 $object = self::createNewNode($node_id, Network::getCurrentNetwork()); 
    158                 return $object; 
    159         } 
    160  
    161         /** Create a new Node in the database  
    162          * @param $node_id The id to be given to the new node 
    163          * @param $network Network object.  The node's network  
    164          * @todo Implement network  
    165          * @return the newly created Node object, or null if there was an error 
    166          */ 
    167         static function createNewNode($node_id, Network $network) 
    168         { 
    169                 global $db; 
     160        static function createNewObject($node_id = null, $network = null) 
     161        { 
     162                global $db; 
     163                if(empty($node_id)) 
     164                { 
     165                        $node_id = get_guid(); 
     166                } 
    170167                $node_id = $db->EscapeString($node_id); 
     168                 
     169                if(empty($network)) 
     170                { 
     171                        $network = Network :: getCurrentNetwork(); 
     172                } 
     173                $network_id = $db->EscapeString($network->getId()); 
     174                 
    171175                $node_deployment_status = $db->EscapeString("IN_PLANNING"); 
    172176                $node_name = _("New node"); 
     
    174178                        throw new Exception(_('This node already exists.')); 
    175179 
    176                 $sql = "INSERT INTO nodes (node_id, creation_date, node_deployment_status, name) VALUES ('$node_id', NOW(),'$node_deployment_status', '$node_name')"; 
     180                $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')"; 
    177181 
    178182                if (!$db->ExecSqlUpdate($sql, false)) 
     
    222226        } 
    223227 
     228        /** Get an interface to create a new node. 
     229        * @param $network Optional:  The network to which the new node will belong, 
     230        * if absent, the user will be prompted. 
     231        * @return html markup 
     232        */ 
     233        public static function getCreateNewObjectUI($network = null) 
     234        { 
     235                $html = ''; 
     236                $html .= _("Create new node with id")." \n"; 
     237                $name = "new_node_id"; 
     238                $html .= "<input type='text' size='10' name='{$name}'>\n"; 
     239                if ($network) 
     240                { 
     241                        $name = "new_node_network_id"; 
     242                        $html .= "<input type='hidden' name='{$name}' value='{$network->getId()}'>\n"; 
     243                } 
     244                else 
     245                { 
     246                        $html .= " "._("in network:")." \n"; 
     247                        $html .= Network :: getSelectNetworkUI('new_node'); 
     248                } 
     249                return $html; 
     250 
     251        } 
     252 
     253        /** Process the new object interface.  
     254         *  Will return the new object if the user has the credentials and the form was fully filled. 
     255         * @return the node object or null if no new node was created. 
     256         */ 
     257        static function processCreateNewObjectUI() 
     258        { 
     259                $retval = null; 
     260                $name = "new_node_id"; 
     261                if (!empty ($_REQUEST[$name])) 
     262                { 
     263                        $node_id = $_REQUEST[$name]; 
     264                        $name = "new_node_network_id"; 
     265                        if (!empty ($_REQUEST[$name])) 
     266                        { 
     267                                $network = Network :: getObject($_REQUEST[$name]); 
     268                        } 
     269                        else 
     270                        { 
     271                                $network = Network :: processSelectNetworkUI('new_node'); 
     272                        } 
     273                        if ($node_id && $network) 
     274                        { 
     275                                if (!$network->hasAdminAccess(User :: getCurrentUser())) 
     276                                { 
     277                                        throw new Exception(_("Access denied")); 
     278                                } 
     279                                $retval = self :: createNewObject($node_id, $network); 
     280                        } 
     281                } 
     282                return $retval; 
     283        } 
     284 
    224285        /** Get an interface to select the deployment status 
    225286        * @param $user_prefix A identifier provided by the programmer to recognise it's generated html form 
     
    258319                global $db; 
    259320                $this->mDb = & $db; 
    260                  
     321 
    261322                $node_id_str = $db->EscapeString($node_id); 
    262323                $sql = "SELECT * FROM nodes WHERE node_id='$node_id_str'"; 
     
    280341        public function getNetwork() 
    281342        { 
    282                         return Network::getObject($this->mRow['network_id']); 
     343                return Network :: getObject($this->mRow['network_id']); 
    283344        } 
    284345 
     
    320381        } 
    321382 
    322     function getCreationDate() 
    323     { 
    324         return $this->mRow['creation_date']; 
    325     } 
     383        function getCreationDate() 
     384        { 
     385                return $this->mRow['creation_date']; 
     386        } 
    326387 
    327388        function getHomePageURL() 
     
    527588        public function isConfiguredSplashOnly() 
    528589        { 
    529                 return (($this->mRow['is_splash_only_node']=='t') ? true : false); 
     590                return (($this->mRow['is_splash_only_node'] == 't') ? true : false); 
    530591        } 
    531592 
     
    539600                { 
    540601                        global $db; 
    541                         $value?$value='TRUE':$value='FALSE'; 
     602                        $value ? $value = 'TRUE' : $value = 'FALSE'; 
    542603                        $retval = $db->ExecSqlUpdate("UPDATE nodes SET is_splash_only_node = {$value} WHERE node_id = '{$this->getId()}'", false); 
    543604                        $this->refresh(); 
    544605                } 
    545606                return $retval; 
    546         }                
    547          
    548          
     607        } 
     608 
    549609        /** The url to show instead of the portal.  If empty, the portal is shown 
    550610         Must be enabled in the Network configuration to have any effect 
     
    554614                return $this->mRow['custom_portal_redirect_url']; 
    555615        } 
    556          
     616 
    557617        /** The url to show instead of the portal.  If empty, the portal is shown 
    558618         Must be enabled in the Network configuration to have any effect 
     
    570630                return $retval; 
    571631        } 
    572          
     632 
    573633        /** Retrieves the admin interface of this object. 
    574634         * @return The HTML fragment for this interface */ 
     
    577637                //TODO: Most of this code will be moved to Hotspot class when the abtraction will be completed 
    578638 
    579 //pretty_print_r($_REQUEST); 
    580 //pretty_print_r($this->mRow); 
     639                //pretty_print_r($_REQUEST); 
     640                //pretty_print_r($this->mRow); 
    581641                $html = ''; 
    582642                $html .= "<div class='admin_container'>\n"; 
     
    600660                // Hashed node_id (this is a workaround since PHP auto-converts HTTP vars var periods, spaces or underscores ) 
    601661                $hashed_node_id = md5($this->getId()); 
    602                  
     662 
    603663                // Name 
    604664                $html .= "<div class='admin_section_container'>\n"; 
     
    794854                $html .= "<div class='admin_section_container'>\n"; 
    795855                $html .= "<div class='admin_section_title'>"._("Node configuration:")."</div>\n"; 
    796                  
     856 
    797857                $network = $this->getNetwork(); 
    798                  
     858 
    799859                // Deployment status 
    800860                $html .= "<div class='admin_section_container'>\n"; 
     
    807867 
    808868                //  is_splash_only_node 
    809                 if($network->getSplashOnlyNodesAllowed()) 
    810                 { 
    811                 $html .= "<div class='admin_section_container'>\n"; 
    812                 $html .= "<div class='admin_section_title'>"._("Is this node splash-only (no login)?")." : </div>\n"; 
    813                 $html .= "<div class='admin_section_data'>\n"; 
    814                 $name = "node_".$hashed_node_id."_is_splash_only_node"; 
    815                 $this->isConfiguredSplashOnly()? $checked='CHECKED': $checked=''; 
    816                 $html .= "<input type='checkbox' name='$name' $checked>\n"; 
    817                 $html .= "</div>\n"; 
    818                 $html .= "</div>\n"; 
    819                 } 
    820                  
    821                                 // custom_portal_redirect_url 
    822                 if($network->getCustomPortalRedirectAllowed()) 
     869                if ($network->getSplashOnlyNodesAllowed()) 
    823870                { 
    824871                        $html .= "<div class='admin_section_container'>\n"; 
    825                 $html .= "<div class='admin_section_title'>"._("URL to show instead of the portal (if this is not empty, the portal will be disabled and this URL will be shown instead)")." : </div>\n"; 
    826                 $html .= "<div class='admin_section_data'>\n"; 
    827                 $name = "node_".$hashed_node_id."_custom_portal_redirect_url"; 
    828                 $value = htmlspecialchars($this->getCustomPortalRedirectUrl(), ENT_QUOTES); 
    829                 $html .= "<input type='text' size ='50' value='$value' name='$name'>\n"; 
    830                 $html .= "</div>\n"; 
    831                 $html .= "</div>\n"; 
     872                        $html .= "<div class='admin_section_title'>"._("Is this node splash-only (no login)?")." : </div>\n"; 
     873                        $html .= "<div class='admin_section_data'>\n"; 
     874                        $name = "node_".$hashed_node_id."_is_splash_only_node"; 
     875                        $this->isConfiguredSplashOnly() ? $checked = 'CHECKED' : $checked = ''; 
     876                        $html .= "<input type='checkbox' name='$name' $checked>\n"; 
     877                        $html .= "</div>\n"; 
     878                        $html .= "</div>\n"; 
     879                } 
     880 
     881                // custom_portal_redirect_url 
     882                if ($network->getCustomPortalRedirectAllowed()) 
     883                { 
     884                        $html .= "<div class='admin_section_container'>\n"; 
     885                        $html .= "<div class='admin_section_title'>"._("URL to show instead of the portal (if this is not empty, the portal will be disabled and this URL will be shown instead)")." : </div>\n"; 
     886                        $html .= "<div class='admin_section_data'>\n"; 
     887                        $name = "node_".$hashed_node_id."_custom_portal_redirect_url"; 
     888                        $value = htmlspecialchars($this->getCustomPortalRedirectUrl(), ENT_QUOTES); 
     889                        $html .= "<input type='text' size ='50' value='$value' name='$name'>\n"; 
     890                        $html .= "</div>\n"; 
     891                        $html .= "</div>\n"; 
    832892                } 
    833893                // End Node configuration section 
    834894                $html .= "</div>\n"; 
    835                  
     895 
    836896                // Owners management 
    837897                $html .= "<div class='admin_section_container'>\n"; 
     
    936996 
    937997                // Information about the node 
    938                  
     998 
    939999                // Hashed node_id (this is a workaround since PHP auto-converts HTTP vars var periods, spaces or underscores ) 
    9401000                $hashed_node_id = md5($this->getId()); 
    941                  
     1001 
    9421002                // Name 
    9431003                $name = "node_".$hashed_node_id."_name"; 
     
    10291089 
    10301090                // Node configuration section 
    1031                  
     1091 
    10321092                $network = $this->getNetwork(); 
    10331093 
     
    10371097 
    10381098                //  is_splash_only_node 
    1039                 if($network->getSplashOnlyNodesAllowed()) 
    1040                 { 
    1041                 $name = "node_".$hashed_node_id."_is_splash_only_node"; 
    1042                 $this->setIsConfiguredSplashOnly(empty($_REQUEST[$name])?false:true);    
    1043                 } 
    1044                  
     1099                if ($network->getSplashOnlyNodesAllowed()) 
     1100                { 
     1101                        $name = "node_".$hashed_node_id."_is_splash_only_node"; 
     1102                        $this->setIsConfiguredSplashOnly(empty ($_REQUEST[$name]) ? false : true); 
     1103                } 
     1104 
    10451105                // custom_portal_redirect_url 
    1046                 if($network->getCustomPortalRedirectAllowed()) 
    1047                 { 
    1048                 $name = "node_".$hashed_node_id."_custom_portal_redirect_url"; 
    1049                 $this->setCustomPortalRedirectUrl($_REQUEST[$name]); 
    1050                 } 
    1051                  
     1106                if ($network->getCustomPortalRedirectAllowed()) 
     1107                { 
     1108                        $name = "node_".$hashed_node_id."_custom_portal_redirect_url"; 
     1109                        $this->setCustomPortalRedirectUrl($_REQUEST[$name]); 
     1110                } 
     1111 
    10521112                // End Node configuration section 
    10531113 
     
    10651125                        } 
    10661126                } 
    1067                  
     1127 
    10681128                $name = "node_{$this->getId()}_new_owner_submit"; 
    10691129                if (!empty ($_REQUEST[$name])) 
     
    14051465                $sql = "SELECT * FROM nodes WHERE node_id='{$id_str}'"; 
    14061466                $db->ExecSqlUniqueRes($sql, $row, false); 
    1407                 if($row!=null) 
     1467                if ($row != null) 
    14081468                { 
    14091469                        $retval = true; 
     
    14301490} // End class 
    14311491?> 
     1492 
     1493 
  • trunk/wifidog-auth/wifidog/classes/User.php

    r739 r742  
    4747        echo "<h1>Use User::createUser() instead</h1>"; 
    4848    } 
    49  
     49                /** Get an interface to create a new object. 
     50        * @return html markup 
     51        */ 
     52        public static function getCreateNewObjectUI() 
     53        { 
     54                return null; 
     55        } 
     56 
     57        /** Process the new object interface.  
     58         *  Will       return the new object if the user has the credentials 
     59         * necessary (Else an exception is thrown) and and the form was fully 
     60         * filled (Else the object returns null). 
     61         * @return the node object or null if no new node was created. 
     62         */ 
     63        static function processCreateNewObjectUI() 
     64{ 
     65        return self::createNewObject(); 
     66} 
    5067        /** Instantiate the current user 
    5168         * @return a User object, or null if there was an error 
  • trunk/wifidog-auth/wifidog/include/schema_validate.php

    r716 r742  
    616616             
    617617                } 
     618                 
     619                $new_schema_version = 28; 
     620                if ($schema_version < $new_schema_version) 
     621                { 
     622                        echo "<h2>Preparing SQL statements to update schema to version  $new_schema_version</h2>\n"; 
     623                        $sql .= "\n\nUPDATE schema_info SET value='$new_schema_version' WHERE tag='schema_version';\n"; 
     624            $sql .= "ALTER TABLE nodes ADD COLUMN is_splash_only_node boolean;\n"; 
     625            $sql .= "ALTER TABLE nodes ALTER COLUMN is_splash_only_node SET DEFAULT FALSE;\n"; 
     626            $sql .= "ALTER TABLE nodes ADD COLUMN custom_portal_redirect_url text;\n"; 
     627             
     628                } 
     629                 
    618630                $db->ExecSqlUpdate("BEGIN;\n$sql\nCOMMIT;\n", true); 
    619631                //$db->ExecSqlUpdate("BEGIN;\n$sql\nROLLBACK;\n", true);