Changeset 687
- Timestamp:
- 08/13/05 01:16:22 (8 years ago)
- Location:
- trunk/wifidog-auth
- Files:
-
- 2 added
- 5 modified
-
.project (added)
-
ChangeLog (modified) (1 diff)
-
wifidog (modified) (1 prop)
-
wifidog/.cvsignore (modified) (1 diff)
-
wifidog/classes/GisPoint.php (added)
-
wifidog/classes/Node.php (modified) (8 diffs)
-
wifidog/include/schema_validate.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog-auth/ChangeLog
r686 r687 1 2005-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 1 7 2005-08-12 Francois Proulx <francois.proulx@gmail.com> 2 8 * Changed config.php GMAPS_API_KEY to GMAPS_PUBLIC_API_KEY -
trunk/wifidog-auth/wifidog
- Property svn:ignore
-
old new 1 1 *~ 2 local.config.php
-
- Property svn:ignore
-
trunk/wifidog-auth/wifidog/.cvsignore
r152 r687 1 1 *~ 2 local.config.php -
trunk/wifidog-auth/wifidog/classes/Node.php
r686 r687 677 677 * Simply use a geocoding service. 678 678 */ 679 /*679 680 680 if(defined('GMAPS_HOTSPOTS_MAP_ENABLED') && GMAPS_HOTSPOTS_MAP_ENABLED === true) 681 681 { … … 688 688 } 689 689 else 690 { */690 { 691 691 $html .= "<div class='admin_section_container'>\n"; 692 692 $html .= "<div class='admin_section_data'>\n"; … … 695 695 $html .= "</div>\n"; 696 696 $html .= "</div>\n"; 697 //}697 } 698 698 699 699 // End of GIS data … … 728 728 $html .= "</div>\n"; 729 729 $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"; 730 756 731 757 // Display stats … … 878 904 } 879 905 } 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"; 882 922 if (!empty ($_REQUEST[$name])) 883 923 { 884 $name = "node_{$this->getId()}_new_ owner";885 $ owner = User :: processSelectUserUI($name);886 if ($ owner)887 { 888 if ($this->is Owner($owner))889 echo _("The user is already a n 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."); 890 930 else 891 $this->add Owner($owner);931 $this->addTechnicalOfficer($tech_officer); 892 932 } 893 933 } … … 1076 1116 return $retval; 1077 1117 } 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) 1080 1138 { 1081 1139 global $db; … … 1083 1141 throw new Exception(_('Could not add owner')); 1084 1142 } 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) 1087 1158 { 1088 1159 global $db; 1089 1160 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)) 1090 1171 throw new Exception(_('Could not remove owner')); 1091 1172 } … … 1108 1189 return $retval; 1109 1190 } 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 } 1110 1209 1111 1210 function nodeExists($id) -
trunk/wifidog-auth/wifidog/include/schema_validate.php
r686 r687 28 28 require_once BASEPATH.'classes/AbstractDb.php'; 29 29 require_once BASEPATH.'classes/Session.php'; 30 define('REQUIRED_SCHEMA_VERSION', 2 2);30 define('REQUIRED_SCHEMA_VERSION', 23); 31 31 32 32 /** Check that the database schema is up to date. If it isn't, offer to update it. */ … … 515 515 $sql .= "ALTER TABLE nodes ADD COLUMN postal_code text;\n"; 516 516 } 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 } 517 529 518 530 $db->ExecSqlUpdate("BEGIN;\n$sql\nCOMMIT;\n", true);
