Changeset 183
- Timestamp:
- 01/02/07 21:53:01 (2 years ago)
- Files:
-
- wifidog/wifidog-auth/wifidog/classes/Network.php (modified) (3 diffs)
- wifidog/wifidog-auth/wifidog/classes/User.php (modified) (11 diffs)
- wifidog/wifidog-auth/wifidog/signup.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
wifidog/wifidog-auth/wifidog/classes/Network.php
r60 r183 99 99 } 100 100 101 101 102 /** Get the default network 102 103 * @return a Network object, NEVER returns null. … … 114 115 return $retval; 115 116 } 117 118 119 // to finish 120 121 public static function getNetworkNameById($id) { 122 $retval = null; 123 global $db; 124 if(empty ($id)) 125 { 126 $retval = ""; 127 } 128 else { 129 $sql = "SELECT name FROM networks WHERE network_id = '$id' LIMIT 1"; 130 $db->execSqlUniqueRes($sql, $network_row, false); 131 if ($network_row == null) { 132 $retval = ""; 133 } 134 else $retval = $network_row['name']; 135 } 136 return $retval; 137 138 } 116 139 117 140 /** Get the current network for which the portal is displayed or to which a user is physically connected. … … 185 208 $selected_id = null; 186 209 } 210 global $db; 211 $additional_where = $db->escapeString($additional_where); 212 $sql = "SELECT network_id, name FROM networks WHERE 1=1 $additional_where ORDER BY is_default_network DESC"; 213 $network_rows = null; 214 $db->execSql($sql, $network_rows, false); 215 if ($network_rows == null) { 216 throw new Exception(_("Network::getAllNetworks: Fatal error: No networks in the database!")); 217 } 218 219 $number_of_networks = count($network_rows); 220 if ($number_of_networks > 1) { 221 $i = 0; 222 foreach ($network_rows as $network_row) { 223 $tab[$i][0] = $network_row['network_id']; 224 $tab[$i][1] = $network_row['name']; 225 $i ++; 226 } 227 $html .= FormSelectGenerator :: generateFromArray($tab, $selected_id, $name, null, false); 228 229 } 230 else { 231 foreach ($network_rows as $network_row) //iterates only once... 232 { 233 $html .= " $network_row[name] "; 234 $html .= "<input type='hidden' name='$name' value='".htmlspecialchars($network_row['network_id'], ENT_QUOTES, 'UTF-8')."'>"; 235 } 236 } 237 238 return $html; 239 } 240 241 public static function getSelectNetworkByNameUI($user_prefix, $selected_id = null, $additional_where = null) { 242 $html = ''; 243 $name = $user_prefix; 244 $html .= _("Network:")." \n"; 245 187 246 global $db; 188 247 $additional_where = $db->escapeString($additional_where); wifidog/wifidog-auth/wifidog/classes/User.php
r179 r183 215 215 * @return the newly created User object, or null if there was an error 216 216 */ 217 static function createUser($id, $username, Network $account_origin, $email, $password, $realname, $birthday, $address, $postalcode, $city, $country, $phone, $network )217 static function createUser($id, $username, Network $account_origin, $email, $password, $realname, $birthday, $address, $postalcode, $city, $country, $phone, $network_id) 218 218 { 219 219 global $db; … … 237 237 $token = User :: generateToken(); 238 238 239 $db->execSqlUpdate("INSERT INTO users (user_id,username, account_origin,email,pass,account_status,validation_token,reg_date,real_name,birthday,address,postalcode,city,country,phone,network) VALUES ('$id_str','$username_str','$account_origin_str','$email_str','$password_hash','$status','$token',NOW(),'$realname_str','$birthday_str','$address_str','$postalcode_str','$city_str','$country_str','$phone_str','$network ')");239 $db->execSqlUpdate("INSERT INTO users (user_id,username, account_origin,email,pass,account_status,validation_token,reg_date,real_name,birthday,address,postalcode,city,country,phone,network) VALUES ('$id_str','$username_str','$account_origin_str','$email_str','$password_hash','$status','$token',NOW(),'$realname_str','$birthday_str','$address_str','$postalcode_str','$city_str','$country_str','$phone_str','$network_id')"); 240 240 241 241 $object = new self($id); … … 746 746 if ($user_rows != null) 747 747 { 748 Utils :: natsort2d($user_rows, "user_id");748 // Utils :: natsort2d($user_rows, "user_id"); 749 749 if ($type_interface != "table") { 750 750 $html .= _("User"); … … 760 760 $html .= FormSelectGenerator :: generateFromArray($tab, null, $name, null, false); 761 761 } else { 762 $html .= "<fieldset>\n\t<legend> Users List</legend>\n";762 $html .= "<fieldset>\n\t<legend>Liste des utilisateurs</legend>\n"; 763 763 $html .= "\t<span class='node_admin'>"._("Filter:")."<input type=\"text\" tabindex=\"1\" maxlength=\"40\" size=\"40\" id=\"nodes_list_filter\" name=\"nodes_list_filter\" /></span>\n\t<br/>\n"; 764 764 $html .= "\t<!--[if IE]><style type='text/css'>#user_list_div table.scrollable>tbody { height: 15px; }</style><![endif]-->\n"; … … 767 767 $html .= "\t<div id='node_list_div' class='node_admin tableContainer'>\n"; 768 768 $html .= "\t\t<table id='nodes_list' class='node_admin filterable scrollable sortable'>\n\n"; 769 $html .= "\t\t\t<thead class='fixedHeader'>\n\t\t\t\t<tr class='nofilter'>\n\t\t\t\t\t<th> User Name</th>\n\t\t\t\t\t<th>Account Status</th>\n\t\t\t\t\t<th>Register Date</th><th>Network</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t<tbody>";769 $html .= "\t\t\t<thead class='fixedHeader'>\n\t\t\t\t<tr class='nofilter'>\n\t\t\t\t\t<th>"._("Username")."</th>\n\t\t\t\t\t<th>"._("Account Status")."</th>\n\t\t\t\t\t<th>"._("Registered On")."</th><th>"._("Network")."</th>\n\t\t\t\t</tr>\n\t\t\t</thead>\n\t\t\t<tbody>"; 770 770 771 771 $i = 0; … … 773 773 { 774 774 $account_status = $user_row['account_status']; 775 $network_name = Network::getNetworkNameById($user_row['network']); 775 776 $href = GENERIC_OBJECT_ADMIN_ABS_HREF."?object_id={$user_row['user_id']}&object_class=User&action=edit"; 776 $html .= "\t\t\t\t<tr class='row' onclick=\"javascript:location.href='{$href}'\">\n\t\t\t\t\t<td>{$user_row['username']}<noscript>(<a href='{$href}'>edit</a>)</noscript></td>\n\t\t\t\t\t<td>". self::getAccountStatusText($account_status) . "</td>\n\t\t\t\t\t<td>{$user_row['reg_date']}</td><td> {$user_row['network']}</td>\n\t\t\t\t</tr>\n";777 $html .= "\t\t\t\t<tr class='row' onclick=\"javascript:location.href='{$href}'\">\n\t\t\t\t\t<td>{$user_row['username']}<noscript>(<a href='{$href}'>edit</a>)</noscript></td>\n\t\t\t\t\t<td>". self::getAccountStatusText($account_status) . "</td>\n\t\t\t\t\t<td>{$user_row['reg_date']}</td><td>$network_name</td>\n\t\t\t\t</tr>\n"; 777 778 } 778 779 $html .= "\t\t\t</tbody>\n\t\t</table>\n"; … … 923 924 // todo: list networks here 924 925 925 926 $html .= "<tr>\n"; 927 $html .= "<td colspan=2>"; 928 $name = "user_".$this->getId()."_network"; 929 $html .= Network::getSelectNetworkByNameUI($name, $this->mRow['network']); 930 $html .= "</td>\n"; 931 $html .= "</tr>\n"; 926 932 } 927 933 … … 930 936 } 931 937 938 public function getNetworkName() 939 { 940 return $this->mRow['network']; 941 } 942 932 943 public function setWebsite($website) 933 944 { … … 1001 1012 } 1002 1013 1003 1004 1014 public function setNetwork($network_id) 1015 { 1016 if (!($update = $this->mDb->execSqlUpdate("UPDATE users SET network='{$network_id}' WHERE user_id='{$this->id}'"))) 1017 { 1018 throw new Exception(_("Could not update network.")); 1019 } 1020 $this->mRow['network'] = $network_id; 1021 } 1005 1022 1006 1023 public function processAdminUI() … … 1009 1026 $currentUser= self::getCurrentUser(); 1010 1027 if($this==$currentUser || $this->getNetwork()->hasAdminAccess($currentUser)) 1011 {1028 { 1012 1029 //username 1013 1030 $name = "user_".$this->getId()."_username"; … … 1050 1067 $this->setAccountStatus($_REQUEST[$account]); 1051 1068 1052 } 1069 // Network 1070 $network = "user_".$this->getId()."_network"; 1071 $this->setNetwork($_REQUEST[$network]); 1072 1073 } 1053 1074 } 1054 1075 wifidog/wifidog-auth/wifidog/signup.php
r174 r183 58 58 require_once('classes/MainUI.php'); 59 59 require_once('classes/Mail.php'); 60 require_once('classes/Network.php'); 60 61 61 62 /** … … 216 217 217 218 $network = Network::getObject($_REQUEST['auth_source']); 219 $network_node = Network::getCurrentNetwork(); 218 220 219 221 try { … … 270 272 271 273 // Create user and send him the validation email 272 $created_user = User::createUser(get_guid(), $username, $network, $email, $password, $realname, $birthday, $address, $postalcode, $city, $country, $phone, $network ->getName());274 $created_user = User::createUser(get_guid(), $username, $network, $email, $password, $realname, $birthday, $address, $postalcode, $city, $country, $phone, $network_node->getId()); 273 275 $created_user->sendValidationEmail(); 274 276
