Changeset 705

Show
Ignore:
Timestamp:
08/31/05 22:41:44 (8 years ago)
Author:
benoitg
Message:

2005-08-31 Benoit Gr�goire <bock@…>

  • Node.php: Fix node creation
Location:
trunk/wifidog-auth
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/ChangeLog

    r704 r705  
     12005-08-31 Benoit Grégoire  <bock@step.polymtl.ca> 
     2        * Node.php:  Fix node creation 
     3 
    142005-08-31 Francois Proulx <francois.proulx@gmail.com> 
    25        * Fixed new node creation bug 
    3          
     6 
    472005-08-29 Philippe April <philippe@ilesansfil.org> 
    58        * js/gmaps_hotspots_status_map.js: Fixed small bug in that makes prevents 
  • trunk/wifidog-auth/wifidog/classes/GenericObject.php

    r553 r705  
    2727require_once BASEPATH.'include/common.php'; 
    2828require_once BASEPATH.'classes/Content.php'; 
    29 /*function __autoload($class_name) { 
    30    require_once BASEPATH.'classes/'.$class_name . '.php'; 
    31 }*/ 
    3229 
    3330/** Any object that implement this interface can be administered in a generic way. */ 
  • trunk/wifidog-auth/wifidog/classes/Network.php

    r697 r705  
    262262                if(!empty ($_REQUEST[$new_node_id])) 
    263263                { 
    264                                 Node::createNode($_REQUEST[$new_node_id], _("Default node name")); 
     264                                Node::createNewNode($_REQUEST[$new_node_id], $this); 
    265265                                $url = GENERIC_OBJECT_ADMIN_ABS_HREF."?".http_build_query(array("object_class" => "Node", "action" => "edit", "object_id" => $_REQUEST[$new_node_id])); 
    266266                                header("Location: {$url}"); 
  • trunk/wifidog-auth/wifidog/classes/Node.php

    r704 r705  
    144144 
    145145        /** Create a new Node in the database 
    146          * @deprecated version - 18-Apr-2005 
    147146         * @param $id The id to be given to the new node 
    148147         * @return the newly created Node object, or null if there was an error 
     
    153152 
    154153                $node_id = $db->EscapeString(get_guid()); 
    155                 $name = $db->EscapeString('New node'); 
    156  
    157                 $sql = "INSERT INTO nodes (node_id, name) VALUES ('$node_id','$name')"; 
    158  
    159                 if (!$db->ExecSqlUpdate($sql, false)) 
    160                 { 
    161                         throw new Exception(_('Unable to insert new node into database!')); 
    162                 } 
    163                 $object = new self($node_id); 
     154                $object = self::createNewNode($node_id, Network::getCurrentNetwork()); 
    164155                return $object; 
    165156        } 
    166157 
    167158        /** Create a new Node in the database  
    168          * @deprecated version - 18-Apr-2005 
    169          * @param $id The id to be given to the new node 
     159         * @param $node_id The id to be given to the new node 
     160         * @param $network Network object.  The node's network  
     161         * @todo Implement network  
    170162         * @return the newly created Node object, or null if there was an error 
    171163         */ 
    172         static function createNode($node_id, $name, $home_page_url = "", $description = "", $map_url = "", $street_name = "", $public_phone_number = "", $public_email = "", $mass_transit_info = "", $node_deployment_status = "IN_PLANNING") 
    173         { 
    174                 global $db; 
    175  
     164        static function createNewNode($node_id, Network $network) 
     165        { 
     166                global $db; 
    176167                $node_id = $db->EscapeString($node_id); 
    177                 $name = $db->EscapeString($name); 
    178                 $home_page_url = $db->EscapeString($home_page_url); 
    179                 $description = $db->EscapeString($description); 
    180                 $map_url = $db->EscapeString($map_url); 
    181                 $street_name = $db->EscapeString($street_name); 
    182                 $public_phone_number = $db->EscapeString($public_phone_number); 
    183                 $public_email = $db->EscapeString($public_email); 
    184                 $mass_transit_info = $db->EscapeString($mass_transit_info); 
    185                 $node_deployment_status = $db->EscapeString($node_deployment_status); 
    186  
     168                $node_deployment_status = $db->EscapeString("IN_PLANNING"); 
     169                $node_name = _("New node"); 
    187170                if (Node :: nodeExists($node_id)) 
    188171                        throw new Exception(_('This node already exists.')); 
    189172 
    190                 $sql = "INSERT INTO nodes (node_id, name, creation_date, home_page_url, description, map_url, street_name, public_phone_number, public_email, mass_transit_info, node_deployment_status) VALUES ('$node_id','$name', NOW(),'$home_page_url','$description','$map_url','$street_name','$public_phone_number','$public_email','$mass_transit_info','$node_deployment_status')"; 
     173                $sql = "INSERT INTO nodes (node_id, creation_date, node_deployment_status, name) VALUES ('$node_id', NOW(),'$node_deployment_status', '$node_name')"; 
    191174 
    192175                if (!$db->ExecSqlUpdate($sql, false)) 
     
    12461229        } 
    12471230 
    1248         function nodeExists($id) 
    1249         { 
    1250                 global $db; 
     1231        /** Check if an node exists */ 
     1232        private function nodeExists($id) 
     1233        { 
     1234                global $db; 
     1235                $retval = false; 
    12511236                $id_str = $db->EscapeString($id); 
    12521237                $sql = "SELECT * FROM nodes WHERE node_id='{$id_str}'"; 
    12531238                $db->ExecSqlUniqueRes($sql, $row, false); 
    1254                 return $row; 
     1239                if($row!=null) 
     1240                { 
     1241                        $retval = true; 
     1242                } 
     1243                return $retval; 
    12551244        } 
    12561245