Changeset 695

Show
Ignore:
Timestamp:
08/21/05 17:27:03 (8 years ago)
Author:
fproulx
Message:

2005-08-21 Francois Proulx <francois.proulx@…>

  • Node admin UI should now be completed.
  • Minor bug fixes in Geocoder
  • Merged node_owners and node_tech_officers table into node_stakeholders
Location:
trunk/wifidog-auth
Files:
2 added
21 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/ChangeLog

    r694 r695  
     12005-08-21 Francois Proulx <francois.proulx@gmail.com> 
     2        * Node admin UI should now be completed. 
     3        * Minor bug fixes in Geocoder 
     4        * Merged node_owners and node_tech_officers table into node_stakeholders 
     5         
    162005-08-19 Benoit Grégoire  <bock@step.polymtl.ca> 
    27        * New schema version 
  • trunk/wifidog-auth/sql/wifidog-postgres-initial-data.sql

    r694 r695  
    119119-- 
    120120 
    121 INSERT INTO schema_info (tag, value) VALUES ('schema_version', '24'); 
     121INSERT INTO schema_info (tag, value) VALUES ('schema_version', '25'); 
    122122 
    123123 
  • trunk/wifidog-auth/sql/wifidog-postgres-schema.sql

    r694 r695  
    294294 
    295295 
    296 SET default_with_oids = false; 
    297  
    298 -- 
    299 -- Name: node_owners; Type: TABLE; Schema: public; Owner: wifidog; Tablespace:  
    300 -- 
    301  
    302 CREATE TABLE node_owners ( 
     296-- 
     297-- Name: node_stakeholders; Type: TABLE; Schema: public; Owner: wifidog; Tablespace:  
     298-- 
     299 
     300CREATE TABLE node_stakeholders ( 
    303301    node_id character varying(32) NOT NULL, 
    304     user_id character varying(45) NOT NULL 
    305 ); 
    306  
    307  
    308 SET default_with_oids = true; 
    309  
    310 -- 
    311 -- Name: node_tech_officers; Type: TABLE; Schema: public; Owner: wifidog; Tablespace:  
    312 -- 
    313  
    314 CREATE TABLE node_tech_officers ( 
    315     node_id character varying(32) NOT NULL, 
    316     user_id character varying(45) NOT NULL 
     302    user_id character varying(45) NOT NULL, 
     303    is_owner boolean DEFAULT false NOT NULL, 
     304    is_tech_officer boolean DEFAULT false NOT NULL 
    317305); 
    318306 
     
    580568 
    581569-- 
    582 -- Name: node_owners_pkey; Type: CONSTRAINT; Schema: public; Owner: wifidog; Tablespace:  
    583 -- 
    584  
    585 ALTER TABLE ONLY node_owners 
    586     ADD CONSTRAINT node_owners_pkey PRIMARY KEY (node_id, user_id); 
    587  
    588  
    589 -- 
    590 -- Name: node_tech_officers_pkey; Type: CONSTRAINT; Schema: public; Owner: wifidog; Tablespace:  
    591 -- 
    592  
    593 ALTER TABLE ONLY node_tech_officers 
    594     ADD CONSTRAINT node_tech_officers_pkey PRIMARY KEY (node_id, user_id); 
     570-- Name: node_stakeholders_pkey; Type: CONSTRAINT; Schema: public; Owner: wifidog; Tablespace:  
     571-- 
     572 
     573ALTER TABLE ONLY node_stakeholders 
     574    ADD CONSTRAINT node_stakeholders_pkey PRIMARY KEY (node_id, user_id); 
    595575 
    596576 
     
    784764 
    785765-- 
     766-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
     767-- 
     768 
     769ALTER TABLE ONLY iframes 
     770    ADD CONSTRAINT "$1" FOREIGN KEY (iframes_id) REFERENCES content(content_id) ON UPDATE CASCADE ON DELETE CASCADE; 
     771 
     772 
     773-- 
     774-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
     775-- 
     776 
     777ALTER TABLE ONLY content_rss_aggregator 
     778    ADD CONSTRAINT "$1" FOREIGN KEY (content_id) REFERENCES content(content_id) ON UPDATE CASCADE ON DELETE CASCADE; 
     779 
     780 
     781-- 
     782-- Name: $1; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
     783-- 
     784 
     785ALTER TABLE ONLY content_rss_aggregator_feeds 
     786    ADD CONSTRAINT "$1" FOREIGN KEY (content_id) REFERENCES content_rss_aggregator(content_id) ON UPDATE CASCADE ON DELETE CASCADE; 
     787 
     788 
     789-- 
    786790-- Name: $2; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    787791-- 
     
    896900 
    897901-- 
    898 -- Name: content_rss_aggregator_content_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    899 -- 
    900  
    901 ALTER TABLE ONLY content_rss_aggregator 
    902     ADD CONSTRAINT content_rss_aggregator_content_id_fkey FOREIGN KEY (content_id) REFERENCES content(content_id) ON UPDATE CASCADE ON DELETE CASCADE; 
    903  
    904  
    905 -- 
    906 -- Name: content_rss_aggregator_feeds_content_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    907 -- 
    908  
    909 ALTER TABLE ONLY content_rss_aggregator_feeds 
    910     ADD CONSTRAINT content_rss_aggregator_feeds_content_id_fkey FOREIGN KEY (content_id) REFERENCES content_rss_aggregator(content_id) ON UPDATE CASCADE ON DELETE CASCADE; 
    911  
    912  
    913 -- 
    914902-- Name: fk_node_deployment_status; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    915903-- 
     
    928916 
    929917-- 
    930 -- Name: fk_nodes; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    931 -- 
    932  
    933 ALTER TABLE ONLY node_owners 
    934     ADD CONSTRAINT fk_nodes FOREIGN KEY (node_id) REFERENCES nodes(node_id) ON UPDATE CASCADE ON DELETE CASCADE; 
    935  
    936  
    937 -- 
    938918-- Name: fk_users; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    939919-- 
     
    944924 
    945925-- 
    946 -- Name: fk_users; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    947 -- 
    948  
    949 ALTER TABLE ONLY node_owners 
    950     ADD CONSTRAINT fk_users FOREIGN KEY (user_id) REFERENCES users(user_id) ON UPDATE CASCADE ON DELETE CASCADE; 
    951  
    952  
    953 -- 
    954926-- Name: fk_venue_types; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    955927-- 
     
    968940 
    969941-- 
    970 -- Name: iframes_iframes_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    971 -- 
    972  
    973 ALTER TABLE ONLY iframes 
    974     ADD CONSTRAINT iframes_iframes_id_fkey FOREIGN KEY (iframes_id) REFERENCES content(content_id) ON UPDATE CASCADE ON DELETE CASCADE; 
    975  
    976  
    977 -- 
    978 -- Name: node_tech_officers_node_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    979 -- 
    980  
    981 ALTER TABLE ONLY node_tech_officers 
    982     ADD CONSTRAINT node_tech_officers_node_id_fkey FOREIGN KEY (node_id) REFERENCES nodes(node_id); 
    983  
    984  
    985 -- 
    986 -- Name: node_tech_officers_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
    987 -- 
    988  
    989 ALTER TABLE ONLY node_tech_officers 
    990     ADD CONSTRAINT node_tech_officers_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(user_id); 
     942-- Name: node_stakeholders_node_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
     943-- 
     944 
     945ALTER TABLE ONLY node_stakeholders 
     946    ADD CONSTRAINT node_stakeholders_node_id_fkey FOREIGN KEY (node_id) REFERENCES nodes(node_id); 
     947 
     948 
     949-- 
     950-- Name: node_stakeholders_user_id_fkey; Type: FK CONSTRAINT; Schema: public; Owner: wifidog 
     951-- 
     952 
     953ALTER TABLE ONLY node_stakeholders 
     954    ADD CONSTRAINT node_stakeholders_user_id_fkey FOREIGN KEY (user_id) REFERENCES users(user_id); 
    991955 
    992956 
  • trunk/wifidog-auth/wifidog/classes/AbstractGeocoder.php

    r686 r695  
    182182        abstract public function getLongitude(); 
    183183        abstract public function getAltitude(); 
     184        abstract public function getGisLocation(); 
    184185 
    185186} // End class 
  • trunk/wifidog-auth/wifidog/classes/Geocoders/GeocoderCanada.php

    r686 r695  
    166166                return null; 
    167167        } 
     168         
     169        /** Get a GIS Point instance  
     170         * @return GisPoint 
     171         */ 
     172        public function getGisLocation() 
     173        { 
     174                $lat = $this->getLatitude(); 
     175                $long = $this->getLongitude(); 
     176                 
     177                if($lat !== null && $long !== null) 
     178                        return new GisPoint($lat, $long, 0); 
     179                return null; 
     180        } 
    168181 
    169182} // End class 
  • trunk/wifidog-auth/wifidog/classes/Geocoders/GeocoderUsa.php

    r686 r695  
    133133                // Not supported by geocoder.us 
    134134                return null; 
    135         }        
     135        } 
     136         
     137        /** Get a GIS Point instance  
     138         * @return GisPoint 
     139         */ 
     140        public function getGisLocation() 
     141        { 
     142                $lat = $this->getLatitude(); 
     143                $long = $this->getLongitude(); 
     144                 
     145                if($lat !== null && $long !== null) 
     146                        return new GisPoint($lat, $long, 0); 
     147                return null; 
     148        } 
     149                 
    136150} // End class 
    137151 
  • trunk/wifidog-auth/wifidog/classes/GisPoint.php

    r687 r695  
    6666                $this->altitude = $alt; 
    6767        } 
    68  
    6968 } 
    7069  
  • trunk/wifidog-auth/wifidog/classes/Locale.php

    r645 r695  
    115115                        if ($current_locale != $locale_id) 
    116116                        { 
    117                                 echo "Warning: language.php: Unable to setlocale() to ".$locale_id.", return value: $current_locale, current locale: ".setlocale(LC_ALL, 0); 
     117                                echo "Warning in /classes/Locale.php : Unable to setlocale() to ".$locale_id.", return value: $current_locale, current locale: ".setlocale(LC_ALL, 0); 
    118118                                $retval = false; 
    119119                        } 
  • trunk/wifidog-auth/wifidog/classes/MainUI.php

    r694 r695  
    125125                                                $sql_additional_where = ''; 
    126126                                        else 
    127                                                 $sql_additional_where = "AND node_id IN (SELECT node_id from node_owners WHERE user_id='".$current_user->getId()."')"; 
     127                                                $sql_additional_where = "AND node_id IN (SELECT node_id from node_stakeholders WHERE is_owner = true AND user_id='".$current_user->getId()."')"; 
    128128                                        $html .= "<div id='NodeSelector'>\n"; 
    129129                                        $html .= Node :: getSelectNodeUI('object_id', $sql_additional_where); 
  • trunk/wifidog-auth/wifidog/classes/Node.php

    r694 r695  
    11<?php 
     2 
    23 
    34/********************************************************************\ 
     
    297298                return new GisPoint($this->mRow['latitude'], $this->mRow['longitude'], 0); 
    298299        } 
    299          
     300 
    300301        function setGisLocation($pt) 
    301302        { 
    302                 if(!empty($pt)) 
     303                if (!empty ($pt)) 
    303304                { 
    304305                        $lat = $this->mDb->EscapeString($pt->getLatitude()); 
    305306                        $long = $this->mDb->EscapeString($pt->getLongitude()); 
    306                          
    307                         $this->mDb->ExecSqlUpdate("UPDATE nodes SET latitude = $lat, longitude = $long WHERE node_id = '{$this->getId()}'"); 
     307 
     308                        if (!empty ($lat) && !empty ($long)) 
     309                                $this->mDb->ExecSqlUpdate("UPDATE nodes SET latitude = $lat, longitude = $long WHERE node_id = '{$this->getId()}'"); 
     310                        else 
     311                                $this->mDb->ExecSqlUpdate("UPDATE nodes SET latitude = NULL, longitude = NULL WHERE node_id = '{$this->getId()}'"); 
    308312                        $this->refresh(); 
    309313                } 
     
    359363                $this->refresh(); 
    360364        } 
    361          
     365 
    362366        public function getCivicNumber() 
    363367        { 
     
    554558                $html .= "</div>\n"; 
    555559                $html .= "</div>\n"; 
    556                  
     560 
    557561                // Street name 
    558562                $html .= "<div class='admin_section_container'>\n"; 
     
    564568                $html .= "</div>\n"; 
    565569                $html .= "</div>\n"; 
    566                  
     570 
    567571                // City 
    568572                $html .= "<div class='admin_section_container'>\n"; 
     
    574578                $html .= "</div>\n"; 
    575579                $html .= "</div>\n"; 
    576                  
     580 
    577581                // Province 
    578582                $html .= "<div class='admin_section_container'>\n"; 
     
    584588                $html .= "</div>\n"; 
    585589                $html .= "</div>\n"; 
    586                  
     590 
    587591                // Postal Code 
    588592                $html .= "<div class='admin_section_container'>\n"; 
     
    594598                $html .= "</div>\n"; 
    595599                $html .= "</div>\n"; 
    596                  
     600 
    597601                // Country 
    598602                $html .= "<div class='admin_section_container'>\n"; 
     
    644648                $html .= "</div>\n"; 
    645649 
     650                // End of information section 
     651                $html .= "</div>\n"; 
     652 
    646653                // Node GIS data 
    647654                $html .= "<div class='admin_section_container'>\n"; 
    648655                $html .= "<div class='admin_section_title'>"._("GIS data")." : </div>\n"; 
    649                  
     656 
    650657                // Build HTML form fields names & values 
    651658                $gis_point = $this->getGisLocation(); 
     
    654661                $gis_long_name = "node_".$this->getId()."_gis_longitude"; 
    655662                $gis_long_value = htmlspecialchars($gis_point->getLongitude(), ENT_QUOTES); 
    656                  
    657                 $html .= "<div class='admin_section_container'>\n";      
     663 
     664                $html .= "<div class='admin_section_container'>\n"; 
    658665                $html .= "<div class='admin_section_title'>"._("Latitude")." : </div>\n"; 
    659666                $html .= "<div class='admin_section_data'>\n"; 
    660                 $html .= "<input type='text' size ='50' value='$gis_lat_value' name='$gis_lat_name'>\n"; 
    661                 $html .= "</div>\n"; 
    662                 $html .= "</div>\n"; 
    663                  
    664                 $html .= "<div class='admin_section_container'>\n";      
     667                $html .= "<input type='text' size ='50' value='$gis_lat_value' id='$gis_lat_name' name='$gis_lat_name'>\n"; 
     668                $html .= "</div>\n"; 
     669                $html .= "</div>\n"; 
     670 
     671                $html .= "<div class='admin_section_container'>\n"; 
    665672                $html .= "<div class='admin_section_title'>"._("Longitude")." : </div>\n"; 
    666673                $html .= "<div class='admin_section_data'>\n"; 
    667                 $html .= "<input type='text' size ='50' value='$gis_long_value' name='$gis_long_name'>\n"; 
    668                 $html .= "</div>\n"; 
    669                 $html .= "</div>\n"; 
    670                  
     674                $html .= "<input type='text' size ='50' value='$gis_long_value' id='$gis_long_name' name='$gis_long_name'>\n"; 
     675                $html .= "</div>\n"; 
     676                $html .= "</div>\n"; 
     677 
    671678                /* 
    672679                 * If Google Maps is enabled, call the geocoding service,  
     
    677684                 * Simply use a geocoding service. 
    678685                 */ 
    679                   
    680                 if(defined('GMAPS_HOTSPOTS_MAP_ENABLED') && GMAPS_HOTSPOTS_MAP_ENABLED === true) 
    681                 { 
    682                         $html .= "<div class='admin_section_container'>\n";      
     686 
     687                if (defined('GMAPS_HOTSPOTS_MAP_ENABLED') && GMAPS_HOTSPOTS_MAP_ENABLED === true) 
     688                { 
     689                        $html .= "<div class='admin_section_container'>\n"; 
    683690                        $html .= "<div class='admin_section_data'>\n"; 
    684                         $html .= "<input type='button' name='google_maps_geocode' value='"._("Geocode location")."' onClick='alert();'>\n"; 
    685                         $html .=" ("._("Use a geocoding service + Google Maps to extract precise GIS data").")";         
     691                        $html .= "<input type='submit' name='geocode_only' value='"._("Geocode only")."'>\n"; 
     692                        $html .= "<input type='button' name='google_maps_geocode' value='"._("Check using Google Maps")."' onClick='window.open(\"hotspot_location_map.php?node_id={$this->getId()}\", \"hotspot_location\", \"toolbar=0,scrollbars=1,resizable=1,location=0,statusbar=0,menubar=0,width=600,height=600\");'>\n"; 
     693                        $html .= " ("._("Use a geocoding service, then use Google Maps to pinpoint the exact location.").")"; 
    686694                        $html .= "</div>\n"; 
    687695                        $html .= "</div>\n"; 
     
    689697                else 
    690698                { 
    691                         $html .= "<div class='admin_section_container'>\n";      
     699                        $html .= "<div class='admin_section_container'>\n"; 
    692700                        $html .= "<div class='admin_section_data'>\n"; 
    693701                        $html .= "<input type='submit' name='geocode_only' value='"._("Geocode location")."'>\n"; 
    694                         $html .=" ("._("Use a geocoding service").")";   
     702                        $html .= " ("._("Use a geocoding service").")"; 
    695703                        $html .= "</div>\n"; 
    696704                        $html .= "</div>\n"; 
    697705                } 
    698                  
     706 
    699707                // End of GIS data 
    700                 $html .= "</div>\n"; 
    701  
    702                 // End of information section 
    703708                $html .= "</div>\n"; 
    704709 
     
    728733                $html .= "</div>\n"; 
    729734                $html .= "</div>\n"; 
    730                  
     735 
    731736                // Tech officers management 
    732737                $html .= "<div class='admin_section_container'>\n"; 
     
    788793                $html .= "</ul>\n"; 
    789794                $html .= "</div>\n"; 
    790                 $html .= "</div>\n"; 
     795 
    791796                return $html; 
    792797        } 
     
    819824                $name = "node_".$this->getId()."_map_url"; 
    820825                $this->setMapUrl($_REQUEST[$name]); 
    821                  
     826 
    822827                // Civic number 
    823828                $name = "node_".$this->getId()."_civic_number"; 
    824829                $this->setCivicNumber($_REQUEST[$name]); 
    825                  
     830 
    826831                // Street name 
    827832                $name = "node_".$this->getId()."_street_name"; 
    828833                $this->setStreetName($_REQUEST[$name]); 
    829                  
     834 
    830835                // City 
    831836                $name = "node_".$this->getId()."_city"; 
    832837                $this->setCity($_REQUEST[$name]); 
    833                  
     838 
    834839                // Province 
    835840                $name = "node_".$this->getId()."_province"; 
    836841                $this->setProvince($_REQUEST[$name]); 
    837                  
     842 
    838843                // Postal Code 
    839844                $name = "node_".$this->getId()."_postal_code"; 
    840845                $this->setPostalCode($_REQUEST[$name]); 
    841                  
     846 
    842847                // Country 
    843848                $name = "node_".$this->getId()."_country"; 
     
    859864                $name = "node_".$this->getId()."_deployment_status"; 
    860865                $this->setDeploymentStatus(self :: processSelectDeploymentStatus($name)); 
    861                  
     866 
    862867                // GIS data 
    863868                // Get a geocoder for a given country 
    864                 if(!empty($_REQUEST['geocode_only'])) 
    865                 { 
    866                         $geocoder = AbstractGeocoder::getGeocoder($this->getCountry()); 
    867                         if($geocoder != null) 
     869                if (!empty ($_REQUEST['geocode_only'])) 
     870                { 
     871                        $geocoder = AbstractGeocoder :: getGeocoder($this->getCountry()); 
     872                        if ($geocoder != null) 
    868873                        { 
    869874                                $geocoder->setCivicNumber($this->getCivicNumber()); 
    870875                                $geocoder->setStreetName($this->getStreetName()); 
    871876                                $geocoder->setCity($this->getCity()); 
    872                                 $geocoder->setProvince($this->getProvince());  
     877                                $geocoder->setProvince($this->getProvince()); 
    873878                                $geocoder->setPostalCode($this->getPostalCode()); 
    874                                 if($geocoder->validateAddress() === true)        
    875                                         $this->setGisLocation(new GisPoint($geocoder->getLatitude(), $geocoder->getLongitude(), .0)); 
     879                                if ($geocoder->validateAddress() === true) 
     880                                { 
     881                                        if (($point = $geocoder->getGisLocation()) !== null) 
     882                                                $this->setGisLocation($point); 
     883                                        else 
     884                                                echo _("It appears that the Geocoder could not be reached or could not geocode the given address."); 
     885                                } 
    876886                                else 
    877887                                        echo _("You must enter a valid address."); 
     
    883893                        $gis_lat_name = "node_".$this->getId()."_gis_latitude"; 
    884894                        $gis_long_name = "node_".$this->getId()."_gis_longitude"; 
    885                         $this->setGisLocation(new GisPoint($_REQUEST[$gis_lat_name], $_REQUEST[$gis_long_name], .0));    
     895                        $this->setGisLocation(new GisPoint($_REQUEST[$gis_lat_name], $_REQUEST[$gis_long_name], .0)); 
    886896                } 
    887897 
     
    905915                } 
    906916                 
     917                $name = "node_{$this->getId()}_new_owner_submit"; 
     918                if (!empty ($_REQUEST[$name])) 
     919                { 
     920                        $name = "node_{$this->getId()}_new_owner"; 
     921                        $owner = User :: processSelectUserUI($name); 
     922                        if ($owner) 
     923                        { 
     924                                if ($this->isOwner($owner)) 
     925                                        echo _("The user is already an owner of this node."); 
     926                                else 
     927                                        $this->addOwner($owner); 
     928                        } 
     929                } 
     930 
    907931                // Technical officers processing 
    908932                // Rebuild user id, and delete if it was selected 
     
    11061130                global $db; 
    11071131                $retval = array (); 
    1108                 $db->ExecSql("SELECT user_id FROM node_owners WHERE node_id='{$this->id}'", $owners, false); 
     1132                $db->ExecSql("SELECT user_id FROM node_stakeholders WHERE is_owner = true AND node_id='{$this->id}'", $owners, false); 
    11091133                if ($owners != null) 
    11101134                { 
     
    11161140                return $retval; 
    11171141        } 
    1118          
     1142 
    11191143        function getTechnicalOfficers() 
    11201144        { 
    11211145                global $db; 
    11221146                $retval = array (); 
    1123                 $db->ExecSql("SELECT user_id FROM node_tech_officers WHERE node_id='{$this->id}'", $officers, false); 
     1147                $db->ExecSql("SELECT user_id FROM node_stakeholders WHERE is_tech_officer = true AND node_id='{$this->id}'", $officers, false); 
    11241148                if ($officers != null) 
    11251149                { 
     
    11381162        { 
    11391163                global $db; 
    1140                 if (!$db->ExecSqlUpdate("INSERT INTO node_owners (node_id, user_id) VALUES ('{$this->getId()}','{$user->getId()}')", false)) 
    1141                         throw new Exception(_('Could not add owner')); 
    1142         } 
    1143          
     1164                $db->ExecSql("SELECT * FROM node_stakeholders WHERE node_id = '{$this->getId()}' AND user_id = '{$user->getId()}'", $rows, false); 
     1165                if (!$rows) 
     1166                { 
     1167                        if (!$db->ExecSqlUpdate("INSERT INTO node_stakeholders (node_id, user_id, is_owner) VALUES ('{$this->getId()}','{$user->getId()}', true)", false)) 
     1168                                throw new Exception(_('Could not add owner')); 
     1169                } 
     1170                else 
     1171                        if (!$db->ExecSqlUpdate("UPDATE node_stakeholders SET is_owner = true WHERE node_id = '{$this->getId()}' AND user_id = '{$user->getId()}';", false)) 
     1172                                throw new Exception(_('Could not add owner')); 
     1173        } 
     1174 
    11441175        /** Associates a technical officer ( tech support ) to this node 
    11451176         * @param User 
     
    11481179        { 
    11491180                global $db; 
    1150                 if (!$db->ExecSqlUpdate("INSERT INTO node_tech_officers (node_id, user_id) VALUES ('{$this->getId()}','{$user->getId()}')", false)) 
    1151                         throw new Exception(_('Could not add technical officer')); 
     1181                $db->ExecSql("SELECT * FROM node_stakeholders WHERE node_id = '{$this->getId()}' AND user_id = '{$user->getId()}'", $rows, false); 
     1182                if (!$rows) 
     1183                { 
     1184                        if (!$db->ExecSqlUpdate("INSERT INTO node_stakeholders (node_id, user_id, is_tech_officer) VALUES ('{$this->getId()}','{$user->getId()}', true)", false)) 
     1185                                throw new Exception(_('Could not add tech officer')); 
     1186                } 
     1187                else 
     1188                        if (!$db->ExecSqlUpdate("UPDATE node_stakeholders SET is_tech_officer = true WHERE node_id = '{$this->getId()}' AND user_id = '{$user->getId()}';", false)) 
     1189                                throw new Exception(_('Could not add tech officer')); 
    11521190        } 
    11531191 
     
    11581196        { 
    11591197                global $db; 
    1160                 if (!$db->ExecSqlUpdate("DELETE FROM node_owners WHERE node_id='{$this->getId()}' AND user_id='{$user->getId()}'", false)) 
     1198                if (!$db->ExecSqlUpdate("UPDATE node_stakeholders SET is_owner = false WHERE node_id = '{$this->getId()}' AND user_id = '{$user->getId()}';", false)) 
    11611199                        throw new Exception(_('Could not remove owner')); 
    11621200        } 
    1163          
     1201 
    11641202        /** Remove a technical officer ( tech support ) from this node 
    11651203         * @param User 
     
    11681206        { 
    11691207                global $db; 
    1170                 if (!$db->ExecSqlUpdate("DELETE FROM node_tech_officers WHERE node_id='{$this->getId()}' AND user_id='{$user->getId()}'", false)) 
    1171                         throw new Exception(_('Could not remove owner')); 
     1208                if (!$db->ExecSqlUpdate("UPDATE node_stakeholders SET is_tech_officer = false WHERE node_id = '{$this->getId()}' AND user_id = '{$user->getId()}';", false)) 
     1209                        throw new Exception(_('Could not remove tech officer')); 
    11721210        } 
    11731211 
     
    11811219                        $user_id = $user->getId(); 
    11821220                        $retval = false; 
    1183                         $db->ExecSqlUniqueRes("SELECT * FROM node_owners WHERE node_id='{$this->id}' AND user_id='{$user_id}'", $row, false); 
     1221                        $db->ExecSqlUniqueRes("SELECT * FROM node_stakeholders WHERE is_owner = true AND node_id='{$this->id}' AND user_id='{$user_id}'", $row, false); 
    11841222                        if ($row != null) 
    11851223                        { 
     
    11891227                return $retval; 
    11901228        } 
    1191          
     1229 
    11921230        /** Is the user a technical officer of the Node?  
    11931231         * @return true our false*/ 
     
    11991237                        $user_id = $user->getId(); 
    12001238                        $retval = false; 
    1201                         $db->ExecSqlUniqueRes("SELECT * FROM node_tech_officers WHERE node_id='{$this->id}' AND user_id='{$user_id}'", $row, false); 
     1239                        $db->ExecSqlUniqueRes("SELECT * FROM node_stakeholders WHERE is_tech_officer = true AND node_id='{$this->id}' AND user_id='{$user_id}'", $row, false); 
    12021240                        if ($row != null) 
    12031241                        { 
  • trunk/wifidog-auth/wifidog/classes/Security.php

    r638 r695  
    7676    $password_hash = $this->session->get(SESS_PASSWORD_HASH_VAR); 
    7777 
    78     $db->ExecSqlUniqueRes("SELECT * FROM users NATURAL JOIN node_owners WHERE (users.user_id='$user') AND pass='$password_hash' AND node_owners.node_id='$node_id'", $user_info, false); 
     78    $db->ExecSqlUniqueRes("SELECT * FROM users NATURAL JOIN node_stakeholders WHERE is_owner = true AND (users.user_id='$user') AND pass='$password_hash' AND node_stakeholders.node_id='$node_id'", $user_info, false); 
    7979    if(empty($user_info)) { 
    8080        echo '<p class=error>'._("You do not have owner privileges")."</p>\n"; 
  • trunk/wifidog-auth/wifidog/classes/User.php

    r686 r695  
    410410        { 
    411411                global $db; 
    412                 $db->ExecSqlUniqueRes("SELECT * FROM node_owners WHERE user_id='{$this->getId()}'", $row, false); 
     412                $db->ExecSqlUniqueRes("SELECT * FROM node_stakeholders WHERE is_owner = true AND user_id='{$this->getId()}'", $row, false); 
    413413                if ($row != null) 
    414414                        return true; 
  • trunk/wifidog-auth/wifidog/hotspot_status.php

    r686 r695  
    203203                                } 
    204204                                 
     205                                // Civic number 
     206                                if (!empty ($node_row['civic_number'])) 
     207                                { 
     208                                        $civic_nbr = $xmldoc->createElement("civicNumber", $node_row['civic_number']); 
     209                                        $hotspot->appendChild($civic_nbr); 
     210                                } 
     211                                 
    205212                                // Street address 
    206213                                if (!empty ($node_row['street_name'])) 
     
    208215                                        $street_addr = $xmldoc->createElement("streetAddress", $node_row['street_name']); 
    209216                                        $hotspot->appendChild($street_addr); 
     217                                } 
     218                                 
     219                                // City 
     220                                if (!empty ($node_row['city'])) 
     221                                { 
     222                                        $city = $xmldoc->createElement("city", $node_row['city']); 
     223                                        $hotspot->appendChild($city); 
     224                                } 
     225                                 
     226                                 
     227                                // Province 
     228                                if (!empty ($node_row['province'])) 
     229                                { 
     230                                        $province = $xmldoc->createElement("province", $node_row['province']); 
     231                                        $hotspot->appendChild($province); 
     232                                } 
     233                                 
     234                                // Postal code 
     235                                if (!empty ($node_row['postal_code'])) 
     236                                { 
     237                                        $postal_code = $xmldoc->createElement("postalCode", $node_row['postal_code']); 
     238                                        $hotspot->appendChild($postal_code); 
     239                                } 
     240                                 
     241                                // Country 
     242                                if (!empty ($node_row['country'])) 
     243                                { 
     244                                        $country = $xmldoc->createElement("country", $node_row['country']); 
     245                                        $hotspot->appendChild($country); 
    210246                                } 
    211247                                 
     
    435471                                $description_text .= "</p>\n"; 
    436472                                $description_text .= "<p>\n"; 
    437                                 if (!empty ($node_row['street_address'])) 
    438                                 { 
    439                                         $description_text .= ""._("Address:")." ".$node_row['street_address']." "; 
    440                                 } 
     473                                $description_text .= ""._("Address:")." "; 
     474                                 
     475                                // Civic number 
     476                                if (!empty ($node_row['civic_number'])) 
     477                                { 
     478                                        $description_text .= $node_row['civic_number'].", "; 
     479                                } 
     480                                 
     481                                if (!empty ($node_row['street_name'])) 
     482                                { 
     483                                        $description_text .= $node_row['street_name'].", "; 
     484                                } 
     485                                 
     486                                // City 
     487                                if (!empty ($node_row['city'])) 
     488                                { 
     489                                        $description_text .= $node_row['city'].", "; 
     490                                } 
     491                                 
     492                                 
     493                                // Province 
     494                                if (!empty ($node_row['province'])) 
     495                                { 
     496                                        $description_text .= $node_row['province'].", "; 
     497                                } 
     498                                 
     499                                // Postal code 
     500                                if (!empty ($node_row['postal_code'])) 
     501                                { 
     502                                        $description_text .= $node_row['postal_code'].", "; 
     503                                } 
     504                                 
     505                                // Country 
     506                                if (!empty ($node_row['country'])) 
     507                                { 
     508                                        $description_text .= $node_row['country']; 
     509                                } 
     510                                 
    441511                                if (!empty ($node_row['map_url'])) 
    442512                                { 
  • trunk/wifidog-auth/wifidog/hotspots_map.php

    r686 r695  
    4949 
    5050// The onLoad code should only be called once all DIV are created. 
    51 $script = "<script type=\"text/javascript\">onLoad('".GMAPS_XML_SOURCE_URL."', ".GMAPS_INITIAL_LATITUDE.", ".GMAPS_INITIAL_LONGITUDE.", ".GMAPS_INITIAL_ZOOM_LEVEL.");</script>\n"; 
     51$script = "<script type=\"text/javascript\">loadHotspotsMap('".GMAPS_XML_SOURCE_URL."', ".GMAPS_INITIAL_LATITUDE.", ".GMAPS_INITIAL_LONGITUDE.", ".GMAPS_INITIAL_ZOOM_LEVEL.");</script>\n"; 
    5252$ui->addFooterScript($script); 
    5353 
  • trunk/wifidog-auth/wifidog/include/common.php

    r686 r695  
    103103define('COMMON_CONTENT_URL', BASE_URL_PATH.LOCAL_CONTENT_REL_PATH.'common/'); 
    104104 
    105 define('GENERIC_OBJECT_ADMIN_ABS_HREF', BASE_URL_PATH.'/admin/generic_object_admin.php'); 
    106 define('CONTENT_ADMIN_ABS_HREF', BASE_URL_PATH.'/admin/content_admin.php'); 
     105define('GENERIC_OBJECT_ADMIN_ABS_HREF', BASE_URL_PATH.'admin/generic_object_admin.php'); 
     106define('CONTENT_ADMIN_ABS_HREF', BASE_URL_PATH.'admin/content_admin.php'); 
    107107 
    108108/** Convert a password hash form a NoCat passwd file into the same format as get_password_hash(). 
  • trunk/wifidog-auth/wifidog/include/schema_validate.php

    r694 r695  
    2828require_once BASEPATH.'classes/AbstractDb.php'; 
    2929require_once BASEPATH.'classes/Session.php'; 
    30 define('REQUIRED_SCHEMA_VERSION', 24); 
     30define('REQUIRED_SCHEMA_VERSION', 25); 
    3131 
    3232/** Check that the database schema is up to date.  If it isn't, offer to update it. */ 
     
    553553                        $sql .= "ALTER TABLE content_rss_aggregator_feeds ADD COLUMN title text; \n"; 
    554554                } 
     555                 
     556                $new_schema_version = 25; 
     557                if ($schema_version < $new_schema_version) 
     558                { 
     559                        echo "<h2>Preparing SQL statements to update schema to version  $new_schema_version</h2>\n"; 
     560                        $sql .= "\n\nUPDATE schema_info SET value='$new_schema_version' WHERE tag='schema_version';\n"; 
     561                        $sql .= "CREATE TABLE node_stakeholders ( \n"; 
     562                        $sql .= "  node_id VARCHAR(32) REFERENCES nodes (node_id),\n"; 
     563                        $sql .= "  user_id VARCHAR(45) REFERENCES users (user_id),\n"; 
     564                        $sql .= "  is_owner BOOLEAN NOT NULL DEFAULT FALSE,\n"; 
     565                        $sql .= "  is_tech_officer BOOLEAN NOT NULL DEFAULT FALSE,\n"; 
     566                        $sql .= "PRIMARY KEY (node_id, user_id)\n"; 
     567                        $sql .= ");\n"; 
     568                        $sql .= "INSERT INTO node_stakeholders (node_id, user_id) SELECT node_id, user_id FROM node_owners UNION SELECT node_id, user_id FROM node_tech_officers;\n"; 
     569                        $sql .= "UPDATE node_stakeholders SET is_owner = true FROM node_owners WHERE node_stakeholders.node_id = node_owners.node_id AND node_stakeholders.user_id = node_owners.user_id;\n"; 
     570                        $sql .= "UPDATE node_stakeholders SET is_tech_officer = true FROM node_tech_officers WHERE node_stakeholders.node_id = node_tech_officers.node_id AND node_stakeholders.user_id = node_tech_officers.user_id;"; 
     571                        $sql .= "DROP TABLE node_owners;\n"; 
     572                        $sql .= "DROP TABLE node_tech_officers;\n"; 
     573                } 
     574                 
    555575                $db->ExecSqlUpdate("BEGIN;\n$sql\nCOMMIT;\n", true); 
    556576                //$db->ExecSqlUpdate("BEGIN;\n$sql\nROLLBACK;\n", true); 
  • trunk/wifidog-auth/wifidog/js/gmaps_hotspots_status_map.js

    r674 r695  
    2020/**@file gmaps_hotspots_status_map.js 
    2121 * JavaScript functions to display a hotspot status map using Google Maps 
    22  * @author Copyright (C) 2005 François Proulx 
     22 * @author Copyright (C) 2005 Francois Proulx <francois.proulx@gmail.com> 
    2323 */ 
    2424 
     
    2626var markers = Array(); 
    2727 
    28 function onLoad(hotspots_status_xml_url, lat, lng, zoom)  
     28function loadHotspotsMap(hotspots_status_xml_url, lat, lng, zoom)  
    2929{  
    3030        // Create the map 
    31         var map = createMap(new GPoint(lng, lat), zoom); 
     31        if(lat != null && lng != null) 
     32                point = new GPoint(lng, lat); 
     33        else 
     34                point = null; 
     35        var map = createMap(point, zoom); 
    3236        var hotspotsList = document.getElementById("map_hotspots_list"); 
    33         loadHotspotsStatus(map, hotspotsList, hotspots_status_xml_url); 
     37        if(hotspots_status_xml_url != null) 
     38                loadHotspotsStatus(map, hotspotsList, hotspots_status_xml_url); 
     39        return map; 
    3440} 
    3541 
     
    4046        map.addControl(new GLargeMapControl()); 
    4147        map.addControl(new GMapTypeControl()); 
    42         map.centerAndZoom(centerPoint, zoomLevel); 
     48        if(centerPoint != null && zoomLevel != null) 
     49                map.centerAndZoom(centerPoint, zoomLevel); 
    4350        return map; 
    4451} 
    4552 
    46 // Debug function 
    47 function activateShowCoords(map) 
     53function setMapClickCallback(map, callback) 
    4854{ 
    49         GEvent.addListener(map, 'click', function(overlay, point) { 
    50                 if (point) 
    51                 { 
    52                         var marker = new GMarker(point); 
    53                         marker.open 
    54                         GEvent.addListener(marker, "click", function() { 
    55                                 marker.openInfoWindowHtml(point.x + " " + point.y); 
    56                         }); 
    57                         map.addOverlay(marker); 
    58                 } 
    59         }); 
     55        GEvent.addListener(map, 'click', callback); 
    6056} 
    6157 
  • trunk/wifidog-auth/wifidog/lib

    • Property svn:ignore
      •  

        old new  
        11*~ 
        22.directory 
         3magpie 
         4smarty 
         5Phlickr 
  • trunk/wifidog-auth/wifidog/lib/.cvsignore

    r152 r695  
    11*~ 
    22.directory 
     3magpie 
     4smarty 
     5Phlickr 
  • trunk/wifidog-auth/wifidog/lib/smarty

    • Property svn:ignore
      •  

        old new  
        1 * 
         1plugins 
         2internals 
         3Smarty.class.php 
         4Smarty_Compiler.class.php 
         5debug.tpl 
         6Config_File.class.php 
  • trunk/wifidog-auth/wifidog/lib/smarty/.cvsignore

    r157 r695  
    1 * 
    2  
     1plugins 
     2internals 
     3Smarty.class.php 
     4Smarty_Compiler.class.php 
     5debug.tpl 
     6Config_File.class.php