Changeset 1331
- Timestamp:
- 03/06/08 22:29:33 (7 months ago)
- Files:
-
- trunk/wifidog-auth/CHANGELOG (modified) (1 diff)
- trunk/wifidog-auth/wifidog/classes/Network.php (modified) (9 diffs)
- trunk/wifidog-auth/wifidog/classes/Node.php (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/wifidog-auth/CHANGELOG
r1330 r1331 1 1 # $Id$ 2 2008-03-06 Benoit Grégoire <bock@step.polymtl.ca> 3 * Fix #438. Not Node::getNumOnlineUsers() will count every users connected (once for every account), except the splash-only user + every mac adresses connecting as the splash-only user. 4 * Network::getNumOnlineUsers() use the same counting method 5 * Network.php: Reformat variables names according to coding standards. 6 2 7 2008-03-02 Benoit Grégoire <bock@step.polymtl.ca> 3 8 * Fix #431: Don't even display the Signup button if none of the networks allow signing up. Allow Authenticators to define the signup URL themselves. trunk/wifidog-auth/wifidog/classes/Network.php
r1316 r1331 507 507 508 508 // Init values 509 $ _retVal = true;509 $retVal = true; 510 510 511 511 if ($value != $this->getCreationDate()) { 512 512 $value = $db->escapeString($value); 513 $ _retVal = $db->execSqlUpdate("UPDATE networks SET creation_date = '{$value}' WHERE network_id = '{$this->getId()}'", false);513 $retVal = $db->execSqlUpdate("UPDATE networks SET creation_date = '{$value}' WHERE network_id = '{$this->getId()}'", false); 514 514 $this->refresh(); 515 515 } 516 516 517 return $ _retVal;517 return $retVal; 518 518 } 519 519 … … 655 655 { 656 656 // Init values 657 $ _authenticators = array ();658 $ _useCache = false;659 $ _cachedData = null;657 $authenticators = array (); 658 $useCache = false; 659 $cachedData = null; 660 660 661 661 // Create new cache object with a lifetime of one week 662 $ _cache = new Cache("AuthenticatorClasses", "ClassFileCaches", 604800);662 $cache = new Cache("AuthenticatorClasses", "ClassFileCaches", 604800); 663 663 664 664 // Check if caching has been enabled. 665 if ($ _cache->isCachingEnabled) {666 $ _cachedData = $_cache->getCachedData("mixed");667 668 if ($ _cachedData) {665 if ($cache->isCachingEnabled) { 666 $cachedData = $cache->getCachedData("mixed"); 667 668 if ($cachedData) { 669 669 // Return cached data. 670 $ _useCache = true;671 $ _authenticators = $_cachedData;672 } 673 } 674 675 if (!$ _useCache) {676 $ _dir = WIFIDOG_ABS_FILE_PATH."classes/Authenticators";677 $ _dirHandle = @ opendir($_dir);678 679 if ($ _dirHandle) {670 $useCache = true; 671 $authenticators = $cachedData; 672 } 673 } 674 675 if (!$useCache) { 676 $dir = WIFIDOG_ABS_FILE_PATH."classes/Authenticators"; 677 $dirHandle = @ opendir($dir); 678 679 if ($dirHandle) { 680 680 // Loop over the directory 681 while (false !== ($ _filename = readdir($_dirHandle))) {681 while (false !== ($filename = readdir($dirHandle))) { 682 682 // Loop through sub-directories of Content 683 if ($ _filename != '.' && $_filename != '..') {684 $ _matches = null;685 686 if (preg_match("/^(.*)\.php$/", $ _filename, $_matches) > 0) {683 if ($filename != '.' && $filename != '..') { 684 $matches = null; 685 686 if (preg_match("/^(.*)\.php$/", $filename, $matches) > 0) { 687 687 // Only add files containing a corresponding Authenticator class 688 if (is_file("{$ _dir}/{$_matches[0]}")) {689 $ _authenticators[] = $_matches[1];688 if (is_file("{$dir}/{$matches[0]}")) { 689 $authenticators[] = $matches[1]; 690 690 } 691 691 } … … 693 693 } 694 694 695 closedir($ _dirHandle);695 closedir($dirHandle); 696 696 } 697 697 else { 698 throw new Exception(_('Unable to open directory ').$ _dir);698 throw new Exception(_('Unable to open directory ').$dir); 699 699 } 700 700 701 701 // Sort the result array 702 sort($ _authenticators);702 sort($authenticators); 703 703 704 704 // Check if caching has been enabled. 705 if ($ _cache->isCachingEnabled) {705 if ($cache->isCachingEnabled) { 706 706 // Save results into cache, because it wasn't saved into cache before. 707 $ _cache->saveCachedData($_authenticators, "mixed");708 } 709 } 710 711 return $ _authenticators;707 $cache->saveCachedData($authenticators, "mixed"); 708 } 709 } 710 711 return $authenticators; 712 712 } 713 713 … … 730 730 731 731 // Init values 732 $ _authenticators = array ();733 734 foreach (self :: getAvailableAuthenticators() as $ _authenticator) {735 $ _authenticators[] = array ($_authenticator, $_authenticator);736 } 737 738 $ _name = $user_prefix;732 $authenticators = array (); 733 734 foreach (self :: getAvailableAuthenticators() as $authenticator) { 735 $authenticators[] = array ($authenticator, $authenticator); 736 } 737 738 $name = $user_prefix; 739 739 740 740 if ($pre_selected_authenticator) { 741 $ _selectedID = $pre_selected_authenticator;741 $selectedID = $pre_selected_authenticator; 742 742 } 743 743 else { 744 $ _selectedID = null;745 } 746 747 $ _html = FormSelectGenerator :: generateFromArray($_authenticators, $_selectedID, $_name, null, false);748 749 return $ _html;744 $selectedID = null; 745 } 746 747 $html = FormSelectGenerator :: generateFromArray($authenticators, $selectedID, $name, null, false); 748 749 return $html; 750 750 } 751 751 … … 1026 1026 1027 1027 // Init values 1028 $ _map_types = array (array ("G_NORMAL_MAP", _("Map")), array ("G_SATELLITE_MAP", _("Satellite")), array ("G_HYBRID_MAP", _("Hybrid")));1029 1030 $ _name = $user_prefix;1028 $map_types = array (array ("G_NORMAL_MAP", _("Map")), array ("G_SATELLITE_MAP", _("Satellite")), array ("G_HYBRID_MAP", _("Hybrid"))); 1029 1030 $name = $user_prefix; 1031 1031 1032 1032 if ($pre_selected_map_type) { 1033 $ _selectedID = $pre_selected_map_type;1033 $selectedID = $pre_selected_map_type; 1034 1034 } 1035 1035 else { 1036 $ _selectedID = null;1037 } 1038 1039 $ _html = FormSelectGenerator :: generateFromArray($_map_types, $_selectedID, $_name, null, false);1040 1041 return $ _html;1036 $selectedID = null; 1037 } 1038 1039 $html = FormSelectGenerator :: generateFromArray($map_types, $selectedID, $name, null, false); 1040 1041 return $html; 1042 1042 } 1043 1043 … … 1078 1078 1079 1079 // Init values 1080 $ _retval = 0;1081 $ _row = null;1082 $ _useCache = false;1083 $ _cachedData = null;1080 $retval = 0; 1081 $row = null; 1082 $useCache = false; 1083 $cachedData = null; 1084 1084 1085 1085 // Create new cache objects (valid for 1 minute) 1086 $ _cache = new Cache('network_'.$this->_id.'_num_users', $this->_id, 60);1086 $cache = new Cache('network_'.$this->_id.'_num_users', $this->_id, 60); 1087 1087 1088 1088 // Check if caching has been enabled. 1089 if ($ _cache->isCachingEnabled) {1090 $ _cachedData = $_cache->getCachedData();1091 1092 if ($ _cachedData) {1089 if ($cache->isCachingEnabled) { 1090 $cachedData = $cache->getCachedData(); 1091 1092 if ($cachedData) { 1093 1093 // Return cached data. 1094 $ _useCache = true;1095 $ _retval = $_cachedData;1096 } 1097 } 1098 1099 if (!$ _useCache) {1094 $useCache = true; 1095 $retval = $cachedData; 1096 } 1097 } 1098 1099 if (!$useCache) { 1100 1100 // Get number of users 1101 $ _network_id = $db->escapeString($this->_id);1102 $db->execSqlUniqueRes("SELECT COUNT(user_id) FROM users WHERE account_origin='$ _network_id'", $_row, false);1101 $network_id = $db->escapeString($this->_id); 1102 $db->execSqlUniqueRes("SELECT COUNT(user_id) FROM users WHERE account_origin='$network_id'", $row, false); 1103 1103 1104 1104 // String has been found 1105 $ _retval = $_row['count'];1105 $retval = $row['count']; 1106 1106 1107 1107 // Check if caching has been enabled. 1108 if ($ _cache->isCachingEnabled) {1108 if ($cache->isCachingEnabled) { 1109 1109 // Save data into cache, because it wasn't saved into cache before. 1110 $ _cache->saveCachedData($_retval);1111 } 1112 } 1113 1114 return $ _retval;1110 $cache->saveCachedData($retval); 1111 } 1112 } 1113 1114 return $retval; 1115 1115 } 1116 1116 … … 1126 1126 1127 1127 // Init values 1128 $ _retval = 0;1129 $ _row = null;1130 $ _useCache = false;1131 $ _cachedData = null;1128 $retval = 0; 1129 $row = null; 1130 $useCache = false; 1131 $cachedData = null; 1132 1132 1133 1133 // Create new cache objects (valid for 1 minute) 1134 $ _cache = new Cache('network_'.$this->_id.'_num_valid_users', $this->_id, 60);1134 $cache = new Cache('network_'.$this->_id.'_num_valid_users', $this->_id, 60); 1135 1135 1136 1136 // Check if caching has been enabled. 1137 if ($ _cache->isCachingEnabled) {1138 $ _cachedData = $_cache->getCachedData();1139 1140 if ($ _cachedData) {1137 if ($cache->isCachingEnabled) { 1138 $cachedData = $cache->getCachedData(); 1139 1140 if ($cachedData) { 1141 1141 // Return cached data. 1142 $ _useCache = true;1143 $ _retval = $_cachedData;1144 } 1145 } 1146 1147 if (!$ _useCache) {1142 $useCache = true; 1143 $retval = $cachedData; 1144 } 1145 } 1146 1147 if (!$useCache) { 1148 1148 // Get number of valid users 1149 $ _network_id = $db->escapeString($this->_id);1150 $db->execSqlUniqueRes("SELECT COUNT(user_id) FROM users WHERE account_status = ".ACCOUNT_STATUS_ALLOWED." AND account_origin='$ _network_id'", $_row, false);1149 $network_id = $db->escapeString($this->_id); 1150 $db->execSqlUniqueRes("SELECT COUNT(user_id) FROM users WHERE account_status = ".ACCOUNT_STATUS_ALLOWED." AND account_origin='$network_id'", $row, false); 1151 1151 // String has been found 1152 $ _retval = $_row['count'];1152 $retval = $row['count']; 1153 1153 1154 1154 // Check if caching has been enabled. 1155 if ($ _cache->isCachingEnabled) {1155 if ($cache->isCachingEnabled) { 1156 1156 // Save data into cache, because it wasn't saved into cache before. 1157 $_cache->saveCachedData($_retval); 1158 } 1159 } 1160 1161 return $_retval; 1162 } 1163 1164 /** 1165 * Find out how many users are online on the entire network or at a 1166 * specific Hotspot on the network 1167 * 1157 $cache->saveCachedData($retval); 1158 } 1159 } 1160 1161 return $retval; 1162 } 1163 1164 /** 1165 * Find out how many users are connected on the entire network 1166 * Counts every user account connected (once for every account), except the splash-only user + every mac adresses connecting as the splash-only user 1168 1167 * @return int Number of online users 1169 1168 */ … … 1174 1173 1175 1174 // Init values 1176 $ _retval = 0;1177 $ _row = null;1178 $ _useCache = false;1179 $ _cachedData = null;1175 $retval = 0; 1176 $row = null; 1177 $useCache = false; 1178 $cachedData = null; 1180 1179 1181 1180 // Create new cache objects (valid for 1 minute) 1182 $ _cache = new Cache('network_'.$this->_id.'_num_online_users', $this->_id, 60);1181 $cache = new Cache('network_'.$this->_id.'_num_online_users', $this->_id, 60); 1183 1182 1184 1183 // Check if caching has been enabled. 1185 if ($ _cache->isCachingEnabled) {1186 $ _cachedData = $_cache->getCachedData();1187 1188 if ($ _cachedData) {1184 if ($cache->isCachingEnabled) { 1185 $cachedData = $cache->getCachedData(); 1186 1187 if ($cachedData) { 1189 1188 // Return cached data. 1190 $ _useCache = true;1191 $ _retval = $_cachedData;1192 } 1193 } 1194 1195 if (!$ _useCache) {1189 $useCache = true; 1190 $retval = $cachedData; 1191 } 1192 } 1193 1194 if (!$useCache) { 1196 1195 // Get number of online users 1197 $_network_id = $db->escapeString($this->_id); 1198 $db->execSqlUniqueRes("SELECT COUNT(conn_id) FROM connections NATURAL JOIN nodes JOIN networks ON (nodes.network_id=networks.network_id AND networks.network_id='$_network_id') "."WHERE connections.token_status='".TOKEN_INUSE."' ", $_row, false); 1196 $network_id = $db->escapeString($this->_id); 1197 $splashOnlyUserId = $this->getSplashOnlyUser()->getId(); 1198 $sql = "SELECT ((SELECT COUNT(DISTINCT users.user_id) as count FROM users,connections NATURAL JOIN nodes JOIN networks ON (nodes.network_id=networks.network_id AND networks.network_id='$network_id') WHERE connections.token_status='".TOKEN_INUSE."' AND users.user_id=connections.user_id AND users.user_id!='{$splashOnlyUserId}') + (SELECT COUNT(DISTINCT connections.user_mac) as count FROM users,connections NATURAL JOIN nodes JOIN networks ON (nodes.network_id=networks.network_id AND networks.network_id='$network_id') WHERE connections.token_status='".TOKEN_INUSE."' AND users.user_id=connections.user_id AND users.user_id='{$splashOnlyUserId}')) AS count"; 1199 $db->execSqlUniqueRes($sql, $row, false); 1200 1201 $retval = $row['count']; 1202 1203 // Check if caching has been enabled. 1204 if ($cache->isCachingEnabled) { 1205 // Save data into cache, because it wasn't saved into cache before. 1206 $cache->saveCachedData($retval); 1207 } 1208 } 1209 1210 return $retval; 1211 } 1212 1213 /** 1214 * Find out how many nodes are registered in this networks's database 1215 * 1216 * @return int Number of nodes 1217 */ 1218 public function getNumNodes() 1219 { 1220 1221 $db = AbstractDb::getObject(); 1222 1223 // Init values 1224 $retval = 0; 1225 $row = null; 1226 $useCache = false; 1227 $cachedData = null; 1228 1229 // Create new cache objects (valid for 5 minutes) 1230 $cache = new Cache('network_'.$this->_id.'_num_nodes', $this->_id, 300); 1231 1232 // Check if caching has been enabled. 1233 if ($cache->isCachingEnabled) { 1234 $cachedData = $cache->getCachedData(); 1235 1236 if ($cachedData) { 1237 // Return cached data. 1238 $useCache = true; 1239 $retval = $cachedData; 1240 } 1241 } 1242 1243 if (!$useCache) { 1244 // Get number of nodes 1245 $network_id = $db->escapeString($this->_id); 1246 $db->execSqlUniqueRes("SELECT COUNT(node_id) FROM nodes WHERE network_id = '$network_id'", $row, false); 1199 1247 1200 1248 // String has been found 1201 $ _retval = $_row['count'];1249 $retval = $row['count']; 1202 1250 1203 1251 // Check if caching has been enabled. 1204 if ($ _cache->isCachingEnabled) {1252 if ($cache->isCachingEnabled) { 1205 1253 // Save data into cache, because it wasn't saved into cache before. 1206 $ _cache->saveCachedData($_retval);1207 } 1208 } 1209 1210 return $ _retval;1211 } 1212 1213 /** 1214 * Find out how many nodes are registered in this networks's database1215 * 1216 * @return int Number of nodes1217 */ 1218 public function getNum Nodes()1219 { 1220 1221 $db = AbstractDb::getObject(); 1222 1223 // Init values 1224 $ _retval = 0;1225 $ _row = null;1226 $ _useCache = false;1227 $ _cachedData = null;1254 $cache->saveCachedData($retval); 1255 } 1256 } 1257 1258 return $retval; 1259 } 1260 1261 /** 1262 * Find out how many nodes are deployed in this networks's database 1263 * 1264 * @return int Number of deployed nodes 1265 */ 1266 public function getNumDeployedNodes() 1267 { 1268 1269 $db = AbstractDb::getObject(); 1270 1271 // Init values 1272 $retval = 0; 1273 $row = null; 1274 $useCache = false; 1275 $cachedData = null; 1228 1276 1229 1277 // Create new cache objects (valid for 5 minutes) 1230 $ _cache = new Cache('network_'.$this->_id.'_num_nodes', $this->_id, 300);1278 $cache = new Cache('network_'.$this->_id.'_num_deployed_nodes', $this->_id, 300); 1231 1279 1232 1280 // Check if caching has been enabled. 1233 if ($ _cache->isCachingEnabled) {1234 $ _cachedData = $_cache->getCachedData();1235 1236 if ($ _cachedData) {1281 if ($cache->isCachingEnabled) { 1282 $cachedData = $cache->getCachedData(); 1283 1284 if ($cachedData) { 1237 1285 // Return cached data. 1238 $ _useCache = true;1239 $ _retval = $_cachedData;1240 } 1241 } 1242 1243 if (!$ _useCache) {1244 // Get number of nodes1245 $ _network_id = $db->escapeString($this->_id);1246 $db->execSqlUniqueRes("SELECT COUNT(node_id) FROM nodes WHERE network_id = '$ _network_id'", $_row, false);1286 $useCache = true; 1287 $retval = $cachedData; 1288 } 1289 } 1290 1291 if (!$useCache) { 1292 // Get number of deployed nodes 1293 $network_id = $db->escapeString($this->_id); 1294 $db->execSqlUniqueRes("SELECT COUNT(node_id) FROM nodes WHERE network_id = '$network_id' AND (node_deployment_status = 'DEPLOYED' OR node_deployment_status = 'NON_WIFIDOG_NODE')", $row, false); 1247 1295 1248 1296 // String has been found 1249 $ _retval = $_row['count'];1297 $retval = $row['count']; 1250 1298 1251 1299 // Check if caching has been enabled. 1252 if ($ _cache->isCachingEnabled) {1300 if ($cache->isCachingEnabled) { 1253 1301 // Save data into cache, because it wasn't saved into cache before. 1254 $_cache->saveCachedData($_retval); 1255 } 1256 } 1257 1258 return $_retval; 1259 } 1260 1261 /** 1262 * Find out how many nodes are deployed in this networks's database 1263 * 1264 * @return int Number of deployed nodes 1265 */ 1266 public function getNumDeployedNodes() 1267 { 1268 1269 $db = AbstractDb::getObject(); 1270 1271 // Init values 1272 $_retval = 0; 1273 $_row = null; 1274 $_useCache = false; 1275 $_cachedData = null; 1276 1277 // Create new cache objects (valid for 5 minutes) 1278 $_cache = new Cache('network_'.$this->_id.'_num_deployed_nodes', $this->_id, 300); 1279 1280 // Check if caching has been enabled. 1281 if ($_cache->isCachingEnabled) { 1282 $_cachedData = $_cache->getCachedData(); 1283 1284 if ($_cachedData) { 1285 // Return cached data. 1286 $_useCache = true; 1287 $_retval = $_cachedData; 1288 } 1289 } 1290 1291 if (!$_useCache) { 1292 // Get number of deployed nodes 1293 $_network_id = $db->escapeString($this->_id); 1294 $db->execSqlUniqueRes("SELECT COUNT(node_id) FROM nodes WHERE network_id = '$_network_id' AND (node_deployment_status = 'DEPLOYED' OR node_deployment_status = 'NON_WIFIDOG_NODE')", $_row, false); 1295 1296 // String has been found 1297 $_retval = $_row['count']; 1298 1299 // Check if caching has been enabled. 1300 if ($_cache->isCachingEnabled) { 1301 // Save data into cache, because it wasn't saved into cache before. 1302 $_cache->saveCachedData($_retval); 1303 } 1304 } 1305 1306 return $_retval; 1302 $cache->saveCachedData($retval); 1303 } 1304 } 1305 1306 return $retval; 1307 1307 } 1308 1308 … … 1320 1320 1321 1321 // Init values 1322 $ _retval = 0;1323 $ _row = null;1324 $ _useCache = false;1325 $ _cachedData = null;1322 $retval = 0; 1323 $row = null; 1324 $useCache = false; 1325 $cachedData = null; 1326 1326 1327 1327 // Create new cache objects (valid for 5 minutes) 1328 1328 if ($nonMonitoredOnly) { 1329 $ _cache = new Cache('network_'.$this->_id.'_num_online_nodes_non_monitored', $this->_id, 300);1329 $cache = new Cache('network_'.$this->_id.'_num_online_nodes_non_monitored', $this->_id, 300); 1330 1330 } else { 1331 $ _cache = new Cache('network_'.$this->_id.'_num_online_nodes', $this->_id, 300);1331 $cache = new Cache('network_'.$this->_id.'_num_online_nodes', $this->_id, 300); 1332 1332 } 1333 1333 1334 1334 // Check if caching has been enabled. 1335 if ($ _cache->isCachingEnabled) {1336 $ _cachedData = $_cache->getCachedData();1337 1338 if ($ _cachedData) {1335 if ($cache->isCachingEnabled) { 1336 $cachedData = $cache->getCachedData(); 1337 1338 if ($cachedData) { 1339 1339 // Return cached data. 1340 $ _useCache = true;1341 $ _retval = $_cachedData;1342 } 1343 } 1344 1345 if (!$ _useCache) {1340 $useCache = true; 1341 $retval = $cachedData; 1342 } 1343 } 1344 1345 if (!$useCache) { 1346 1346 // Get number of online nodes 1347 $ _network_id = $db->escapeString($this->_id);1347 $network_id = $db->escapeString($this->_id); 1348 1348 1349 1349 if ($nonMonitoredOnly) { 1350 $db->execSqlUniqueRes("SELECT COUNT(node_id) FROM nodes WHERE network_id = '$ _network_id' AND node_deployment_status = 'NON_WIFIDOG_NODE' AND ((CURRENT_TIMESTAMP-last_heartbeat_timestamp) >= interval '5 minutes')", $_row, false);1350 $db->execSqlUniqueRes("SELECT COUNT(node_id) FROM nodes WHERE network_id = '$network_id' AND node_deployment_status = 'NON_WIFIDOG_NODE' AND ((CURRENT_TIMESTAMP-last_heartbeat_timestamp) >= interval '5 minutes')", $row, false); 1351 1351 } else { 1352 $db->execSqlUniqueRes("SELECT COUNT(node_id) FROM nodes WHERE network_id = '$ _network_id' AND (node_deployment_status = 'DEPLOYED' OR node_deployment_status = 'NON_WIFIDOG_NODE') AND ((CURRENT_TIMESTAMP-last_heartbeat_timestamp) < interval '5 minutes')", $_row, false);1352 $db->execSqlUniqueRes("SELECT COUNT(node_id) FROM nodes WHERE network_id = '$network_id' AND (node_deployment_status = 'DEPLOYED' OR node_deployment_status = 'NON_WIFIDOG_NODE') AND ((CURRENT_TIMESTAMP-last_heartbeat_timestamp) < interval '5 minutes')", $row, false); 1353 1353 } 1354 1354 1355 1355 // String has been found 1356 $ _retval = $_row['count'];1356 $retval = $row['count']; 1357 1357 1358 1358 // Check if caching has been enabled. 1359 if ($ _cache->isCachingEnabled) {1359 if ($cache->isCachingEnabled) { 1360 1360 // Save data into cache, because it wasn't saved into cache before. 1361 $ _cache->saveCachedData($_retval);1362 } 1363 } 1364 1365 return $ _retval;1361 $cache->saveCachedData($retval); 1362 } 1363 } 1364 1365 return $retval; 1366 1366 } 1367 1367 trunk/wifidog-auth/wifidog/classes/Node.php
r1324 r1331 1105 1105 } 1106 1106 else { 1107 $_title = _("Name");1107 $_title = _("Name"); 1108 1108 $_data = $this->getName(); 1109 1109 $_html_node_information[] = InterfaceElements::generateAdminSectionContainer("node_name", $_title, $_data); … … 1309 1309 1310 1310 // Creation date 1311 $permArray = null;1311 $permArray = null; 1312 1312 $permArray[]=array(Permission::P('NETWORK_PERM_EDIT_ANY_NODE_CONFIG'), $network); 1313 1313 $permArray[]=array(Permission::P('NODE_PERM_EDIT_DEPLOYMENT_DATE'), $this); … … 1573 1573 /** 1574 1574 * Find out how many users are online this specific Node 1575 * 1575 * Counts every user account connected (once for every account), except the splash-only user + every mac adresses connecting as the splash-only user 1576 1576 * @return int Number of online users 1577 1577 * … … 1580 1580 public function getNumOnlineUsers() 1581 1581 { 1582 1583 1582 $db = AbstractDb::getObject(); 1584 1585 1583 // Init values 1586 1584 $retval = array (); 1587 1585 $row = null; 1588 1589 if (!$this->isConfiguredSplashOnly()) { 1590 $db->execSqlUniqueRes("SELECT COUNT(DISTINCT users.user_id) as count FROM users,connections WHERE connections.token_status='".TOKEN_INUSE."' AND users.user_id=connections.user_id AND connections.node_id='{$this->id}'", $row, false); 1591 } else { 1592 $db->execSqlUniqueRes("SELECT COUNT(DISTINCT connections.user_mac) as count FROM connections WHERE connections.token_status='".TOKEN_INUSE."' AND connections.node_id='{$this->id}'", $row, false); 1593 } 1586 $splashOnlyUserId = $this->getNetwork()->getSplashOnlyUser()->getId(); 1587 $sql = "SELECT ((SELECT COUNT(DISTINCT users.user_id) as count FROM users,connections WHERE connections.token_status='".TOKEN_INUSE."' AND users.user_id=connections.user_id AND connections.node_id='{$this->id}' AND users.user_id!='{$splashOnlyUserId}') + (SELECT COUNT(DISTINCT connections.user_mac) as count FROM users,connections WHERE connections.token_status='".TOKEN_INUSE."' AND users.user_id=connections.user_id AND connections.node_id='{$this->id}' AND users.user_id='{$splashOnlyUserId}')) AS count"; 1588 $db->execSqlUniqueRes($sql, $row, false); 1594 1589 1595 1590 return $row['count'];
