Changeset 687

Show
Ignore:
Timestamp:
08/13/05 01:16:22 (8 years ago)
Author:
fproulx
Message:

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

  • Added missing GisPoint? fille to CVS
  • Fixed some bugs
  • Added Technical officer table
  • Added technical officer management to node UI
Location:
trunk/wifidog-auth
Files:
2 added
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/ChangeLog

    r686 r687  
     12005-08-12 Francois Proulx <francois.proulx@gmail.com> 
     2        * Added missing GisPoint fille to CVS 
     3        * Fixed some bugs 
     4        * Added Technical officer table 
     5        * Added technical officer management to node UI 
     6         
    172005-08-12 Francois Proulx <francois.proulx@gmail.com> 
    28        * Changed config.php GMAPS_API_KEY to GMAPS_PUBLIC_API_KEY 
  • trunk/wifidog-auth/wifidog

    • Property svn:ignore
      •  

        old new  
        11*~ 
         2local.config.php 
  • trunk/wifidog-auth/wifidog/.cvsignore

    r152 r687  
    11*~ 
     2local.config.php 
  • trunk/wifidog-auth/wifidog/classes/Node.php

    r686 r687  
    677677                 * Simply use a geocoding service. 
    678678                 */ 
    679                  /* 
     679                  
    680680                if(defined('GMAPS_HOTSPOTS_MAP_ENABLED') && GMAPS_HOTSPOTS_MAP_ENABLED === true) 
    681681                { 
     
    688688                } 
    689689                else 
    690                 {*/ 
     690                { 
    691691                        $html .= "<div class='admin_section_container'>\n";      
    692692                        $html .= "<div class='admin_section_data'>\n"; 
     
    695695                        $html .= "</div>\n"; 
    696696                        $html .= "</div>\n"; 
    697                 //} 
     697                } 
    698698                 
    699699                // End of GIS data 
     
    728728                $html .= "</div>\n"; 
    729729                $html .= "</div>\n"; 
     730                 
     731                // Tech officers management 
     732                $html .= "<div class='admin_section_container'>\n"; 
     733                $html .= "<div class='admin_section_title'>"._("Technical officers")." : </div>\n"; 
     734                $html .= "<ul class='admin_section_list'>\n"; 
     735                foreach ($this->getTechnicalOfficers() as $tech_officer) 
     736                { 
     737                        $html .= "<li class='admin_section_list_item'>\n"; 
     738                        $html .= "<div class='admin_section_data'>\n"; 
     739                        $html .= "{$tech_officer->getUsername()}"; 
     740                        $html .= "</div>\n"; 
     741                        $html .= "<div class='admin_section_tools'>\n"; 
     742                        $name = "node_{$this->getId()}_tech_officer_{$tech_officer->GetId()}_remove"; 
     743                        $html .= "<input type='submit' name='$name' value='"._("Remove technical officer")."'>"; 
     744                        $html .= "</div>\n"; 
     745                        $html .= "</li>\n"; 
     746                } 
     747                $html .= "<li class='admin_section_list_item'>\n"; 
     748                $name = "node_{$this->getId()}_new_tech_officer"; 
     749                $html .= User :: getSelectUserUI($name); 
     750                $name = "node_{$this->getId()}_new_tech_officer_submit"; 
     751                $html .= "<input type='submit' name='$name' value='"._("Add technical officer")."'>"; 
     752                $html .= "</li>\n"; 
     753                $html .= "</ul>\n"; 
     754                $html .= "</div>\n"; 
     755                $html .= "</div>\n"; 
    730756 
    731757                // Display stats 
     
    878904                        } 
    879905                } 
    880  
    881                 $name = "node_{$this->getId()}_new_owner_submit"; 
     906                 
     907                // Technical officers processing 
     908                // Rebuild user id, and delete if it was selected 
     909                foreach ($this->getTechnicalOfficers() as $tech_officer) 
     910                { 
     911                        $name = "node_{$this->getId()}_tech_officer_{$tech_officer->GetId()}_remove"; 
     912                        if (!empty ($_REQUEST[$name])) 
     913                        { 
     914                                if ($this->isTechnicalOfficer($tech_officer)) 
     915                                        $this->removeTechnicalOfficer($tech_officer); 
     916                                else 
     917                                        echo _("Invalid user!"); 
     918                        } 
     919                } 
     920 
     921                $name = "node_{$this->getId()}_new_tech_officer_submit"; 
    882922                if (!empty ($_REQUEST[$name])) 
    883923                { 
    884                         $name = "node_{$this->getId()}_new_owner"; 
    885                         $owner = User :: processSelectUserUI($name); 
    886                         if ($owner) 
    887                         { 
    888                                 if ($this->isOwner($owner)) 
    889                                         echo _("The user is already an owner of this node."); 
     924                        $name = "node_{$this->getId()}_new_tech_officer"; 
     925                        $tech_officer = User :: processSelectUserUI($name); 
     926                        if ($tech_officer) 
     927                        { 
     928                                if ($this->isTechnicalOfficer($tech_officer)) 
     929                                        echo _("The user is already a technical officer of this node."); 
    890930                                else 
    891                                         $this->addOwner($owner); 
     931                                        $this->addTechnicalOfficer($tech_officer); 
    892932                        } 
    893933                } 
     
    10761116                return $retval; 
    10771117        } 
    1078  
    1079         function addOwner($user) 
     1118         
     1119        function getTechnicalOfficers() 
     1120        { 
     1121                global $db; 
     1122                $retval = array (); 
     1123                $db->ExecSql("SELECT user_id FROM node_tech_officers WHERE node_id='{$this->id}'", $officers, false); 
     1124                if ($officers != null) 
     1125                { 
     1126                        foreach ($officers as $officer_row) 
     1127                        { 
     1128                                $retval[] = User :: getObject($officer_row['user_id']); 
     1129                        } 
     1130                } 
     1131                return $retval; 
     1132        } 
     1133 
     1134        /** Associates an owner to this node 
     1135         * @param User 
     1136         */ 
     1137        function addOwner(User $user) 
    10801138        { 
    10811139                global $db; 
     
    10831141                        throw new Exception(_('Could not add owner')); 
    10841142        } 
    1085  
    1086         function removeOwner($user) 
     1143         
     1144        /** Associates a technical officer ( tech support ) to this node 
     1145         * @param User 
     1146         */ 
     1147        function addTechnicalOfficer(User $user) 
     1148        { 
     1149                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')); 
     1152        } 
     1153 
     1154        /** Remove a technical officer ( tech support ) from this node 
     1155         * @param User 
     1156         */ 
     1157        function removeOwner(User $user) 
    10871158        { 
    10881159                global $db; 
    10891160                if (!$db->ExecSqlUpdate("DELETE FROM node_owners WHERE node_id='{$this->getId()}' AND user_id='{$user->getId()}'", false)) 
     1161                        throw new Exception(_('Could not remove owner')); 
     1162        } 
     1163         
     1164        /** Remove a technical officer ( tech support ) from this node 
     1165         * @param User 
     1166         */ 
     1167        function removeTechnicalOfficer(User $user) 
     1168        { 
     1169                global $db; 
     1170                if (!$db->ExecSqlUpdate("DELETE FROM node_tech_officers WHERE node_id='{$this->getId()}' AND user_id='{$user->getId()}'", false)) 
    10901171                        throw new Exception(_('Could not remove owner')); 
    10911172        } 
     
    11081189                return $retval; 
    11091190        } 
     1191         
     1192        /** Is the user a technical officer of the Node?  
     1193         * @return true our false*/ 
     1194        function isTechnicalOfficer(User $user) 
     1195        { 
     1196                global $db; 
     1197                if ($user != null) 
     1198                { 
     1199                        $user_id = $user->getId(); 
     1200                        $retval = false; 
     1201                        $db->ExecSqlUniqueRes("SELECT * FROM node_tech_officers WHERE node_id='{$this->id}' AND user_id='{$user_id}'", $row, false); 
     1202                        if ($row != null) 
     1203                        { 
     1204                                $retval = true; 
     1205                        } 
     1206                } 
     1207                return $retval; 
     1208        } 
    11101209 
    11111210        function nodeExists($id) 
  • trunk/wifidog-auth/wifidog/include/schema_validate.php

    r686 r687  
    2828require_once BASEPATH.'classes/AbstractDb.php'; 
    2929require_once BASEPATH.'classes/Session.php'; 
    30 define('REQUIRED_SCHEMA_VERSION', 22); 
     30define('REQUIRED_SCHEMA_VERSION', 23); 
    3131 
    3232/** Check that the database schema is up to date.  If it isn't, offer to update it. */ 
     
    515515                        $sql .= "ALTER TABLE nodes ADD COLUMN postal_code text;\n"; 
    516516                } 
     517                 
     518                $new_schema_version = 23; 
     519                if ($schema_version < $new_schema_version) 
     520                { 
     521                        echo "<h2>Preparing SQL statements to update schema to version  $new_schema_version</h2>\n"; 
     522                        $sql .= "\n\nUPDATE schema_info SET value='$new_schema_version' WHERE tag='schema_version';\n"; 
     523                        $sql .= "CREATE TABLE node_tech_officers (\n"; 
     524                        $sql .= "  node_id VARCHAR(32) REFERENCES nodes (node_id),\n"; 
     525                        $sql .= "  user_id VARCHAR(45) REFERENCES users (user_id),\n"; 
     526                        $sql .= "PRIMARY KEY (node_id, user_id)\n"; 
     527                        $sql .= ");\n"; 
     528                } 
    517529 
    518530                $db->ExecSqlUpdate("BEGIN;\n$sql\nCOMMIT;\n", true);