Changeset 1141
- Timestamp:
- 11/24/06 15:04:51 (6 years ago)
- Location:
- trunk/wifidog-auth
- Files:
-
- 4 modified
-
CHANGELOG (modified) (1 diff)
-
wifidog/include/schema_validate.php (modified) (1 diff)
-
wifidog/node_list.php (modified) (6 diffs)
-
wifidog/templates/node_list.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog-auth/CHANGELOG
r1140 r1141 5 5 * Make the google-map locator for nodes use the network center coordinates. 6 6 This change makes it usable when you didn't use the geocoder first. 7 * Show the gateway id in the technical nodelist. 7 8 8 9 2006-11-22 Benoit Grégoire <bock@step.polymtl.ca> -
trunk/wifidog-auth/wifidog/include/schema_validate.php
r1134 r1141 173 173 $sql = ''; 174 174 $db = AbstractDb :: getObject(); 175 $db->execSqlUniqueRes("SELECT * FROM schema_info WHERE tag='schema_version'", $row, false); 175 $db->execSqlUniqueRes("SELECT * FROM schema_info WHERE tag='schema_version'", $row, false);//Re-check the schema version, it could have been updated by another thread 176 176 $schema_version = $row['value']; 177 177 -
trunk/wifidog-auth/wifidog/node_list.php
r1135 r1141 1 1 <?php 2 2 3 3 4 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ … … 52 53 * Load required files 53 54 */ 54 require_once (dirname(__FILE__) . '/include/common.php');55 require_once (dirname(__FILE__) . '/include/common.php'); 55 56 56 require_once ('include/common_interface.php');57 require_once ('classes/Node.php');58 require_once ('classes/Utils.php');59 $smarty = SmartyWifidog ::getObject();60 $db = AbstractDb ::getObject();57 require_once ('include/common_interface.php'); 58 require_once ('classes/Node.php'); 59 require_once ('classes/Utils.php'); 60 $smarty = SmartyWifidog :: getObject(); 61 $db = AbstractDb :: getObject(); 61 62 62 63 // Set the sort parameter, defaults to name 63 if (empty ($_REQUEST["sort_by"])) 64 { 64 if (empty ($_REQUEST["sort_by"])) { 65 65 $sort_by_param = DEFAULT_SORT_BY_PARAM; 66 66 $sort_by_using_sql = true; 67 67 } 68 else 69 { 68 else { 70 69 // Validate sort parameters 71 switch ($_REQUEST["sort_by"]) 72 { 70 switch ($_REQUEST["sort_by"]) { 73 71 // SQL sort parameters 74 72 case "last_heartbeat_user_agent" : 75 case "name" : 76 case "creation_date" : 77 // Fall-through valid parameters 78 $sort_by_param = $_REQUEST["sort_by"]; 79 $sort_by_using_sql = true; 80 break; 81 // Abstraction-driven sort parameters 82 case "node_id" : 83 case "num_online_users" : 84 $sort_by_param = $_REQUEST["sort_by"]; 85 $sort_by_using_sql = false; 86 break; 87 default : 88 $sort_by_param = DEFAULT_SORT_BY_PARAM; 89 $sort_by_using_sql = true; 90 } 91 } 92 93 // Check if ordering should ignore uppper and lower case 94 if ($sort_by_param == "name" || $sort_by_param == "node_id") { 95 $sort_by_param = "lower(" . $sort_by_param . ")"; 73 case "name" : 74 case "creation_date" : 75 case "gw_id" : 76 // Fall-through valid parameters 77 $sort_by_param = $_REQUEST["sort_by"]; 78 $sort_by_using_sql = true; 79 break; 80 // Abstraction-driven sort parameters 81 case "node_id" : 82 case "num_online_users" : 83 $sort_by_param = $_REQUEST["sort_by"]; 84 $sort_by_using_sql = false; 85 break; 86 default : 87 $sort_by_param = DEFAULT_SORT_BY_PARAM; 88 $sort_by_using_sql = true; 89 } 96 90 } 97 91 98 92 // Sort according to above instructions 99 if ($sort_by_using_sql === true) 100 $sql = "SELECT node_id, gw_id, name, last_heartbeat_user_agent, (CURRENT_TIMESTAMP-last_heartbeat_timestamp) AS since_last_heartbeat, last_heartbeat_ip, CASE WHEN ((CURRENT_TIMESTAMP-last_heartbeat_timestamp) < interval '5 minutes') THEN true ELSE false END AS online, creation_date, node_deployment_status FROM nodes WHERE node_deployment_status != 'PERMANENTLY_CLOSED' ORDER BY {$sort_by_param}"; 101 else 102 $sql = "SELECT node_id, gw_id, name, last_heartbeat_user_agent, (CURRENT_TIMESTAMP-last_heartbeat_timestamp) AS since_last_heartbeat, last_heartbeat_ip, CASE WHEN ((CURRENT_TIMESTAMP-last_heartbeat_timestamp) < interval '5 minutes') THEN true ELSE false END AS online, creation_date, node_deployment_status FROM nodes WHERE node_deployment_status != 'PERMANENTLY_CLOSED' ORDER BY ".DEFAULT_SORT_BY_PARAM; 93 if ($sort_by_using_sql === true) { 94 // Check if ordering should ignore uppper and lower case 95 if ($sort_by_param == "name" || $sort_by_param == "node_id") { 96 $sort_by_param_sql = "lower(" . $sort_by_param . ")"; 97 } 98 else { 99 $sort_by_param_sql = $sort_by_param; 100 } 101 $sql = "SELECT node_id, gw_id, name, last_heartbeat_user_agent, (CURRENT_TIMESTAMP-last_heartbeat_timestamp) AS since_last_heartbeat, last_heartbeat_ip, CASE WHEN ((CURRENT_TIMESTAMP-last_heartbeat_timestamp) < interval '5 minutes') THEN true ELSE false END AS online, creation_date, node_deployment_status FROM nodes WHERE node_deployment_status != 'PERMANENTLY_CLOSED' ORDER BY {$sort_by_param_sql}"; 102 } 103 else { 104 $sql = "SELECT node_id, gw_id, name, last_heartbeat_user_agent, (CURRENT_TIMESTAMP-last_heartbeat_timestamp) AS since_last_heartbeat, last_heartbeat_ip, CASE WHEN ((CURRENT_TIMESTAMP-last_heartbeat_timestamp) < interval '5 minutes') THEN true ELSE false END AS online, creation_date, node_deployment_status FROM nodes WHERE node_deployment_status != 'PERMANENTLY_CLOSED' ORDER BY " . DEFAULT_SORT_BY_PARAM; 105 } 103 106 $nodes_results = null; 104 107 $db->execSql($sql, $nodes_results, false); … … 107 110 throw new Exception(_("No nodes could not be found in the database")); 108 111 109 $deploymentStatuses = array( 110 "DEPLOYED" => _("Deployed"), 111 "IN_PLANNING" => _("In planning"), 112 "IN_TESTING" => _("In testing"), 113 "NON_WIFIDOG_NODE" => _("Non-Wifidog node"), 114 "PERMANENTLY_CLOSED" => _("Permanently closed"), 115 "TEMPORARILY_CLOSED" => _("Temporarily closed") 116 ); 112 $deploymentStatuses = array ( 113 "DEPLOYED" => _("Deployed" 114 ), "IN_PLANNING" => _("In planning"), "IN_TESTING" => _("In testing"), "NON_WIFIDOG_NODE" => _("Non-Wifidog node"), "PERMANENTLY_CLOSED" => _("Permanently closed"), "TEMPORARILY_CLOSED" => _("Temporarily closed")); 117 115 118 116 $nodes_list = array (); 119 foreach ($nodes_results as $node_row) 120 { 117 foreach ($nodes_results as $node_row) { 121 118 $node = Node :: getObject($node_row['node_id']); 122 119 $node_row['duration'] = $db->GetDurationArrayFromIntervalStr($node_row['since_last_heartbeat']); … … 128 125 129 126 // Sort using PHP 130 if ($sort_by_using_sql === false) 131 { 127 if ($sort_by_using_sql === false) { 132 128 // Using natural-sort algorithm . 133 switch ($sort_by_param) 134 { 129 switch ($sort_by_param) { 135 130 case "node_id" : 136 Utils ::natsort2d($nodes_list, "node_id");131 Utils :: natsort2d($nodes_list, "node_id"); 137 132 break; 138 133 case "num_online_users" : 139 Utils ::natsort2d($nodes_list, "num_online_users");134 Utils :: natsort2d($nodes_list, "num_online_users"); 140 135 break; 141 136 } … … 146 141 $smarty->assign("sort_by_param", $sort_by_param); 147 142 148 require_once ('classes/MainUI.php');143 require_once ('classes/MainUI.php'); 149 144 150 $ui = MainUI ::getObject();145 $ui = MainUI :: getObject(); 151 146 $ui->addContent('main_area_middle', $smarty->fetch("templates/node_list.html")); 152 147 $ui->display(); … … 159 154 * End: 160 155 */ 161 162 156 ?> -
trunk/wifidog-auth/wifidog/templates/node_list.html
r1138 r1141 8 8 {if $sort_by_param == "last_heartbeat_user_agent"}<img src="{$common_images_url}sort_by_asc.gif">{/if} 9 9 </th> 10 {* <th> 11 <a href="?sort_by=node_id">{"Node id"|_}</a> 12 {if $sort_by_param == "node_id"}<img src="{$common_images_url}sort_by_asc.gif">{/if} 13 </th> *} 10 14 <th> 11 <a href="?sort_by= node_id">{"Id"|_}</a>12 {if $sort_by_param == " node_id"}<img src="{$common_images_url}sort_by_asc.gif">{/if}15 <a href="?sort_by=gw_id">{"Gateway id"|_}</a> 16 {if $sort_by_param == "gw_id"}<img src="{$common_images_url}sort_by_asc.gif">{/if} 13 17 </th> 14 18 <th> … … 38 42 {$nodes[node].last_heartbeat_user_agent} 39 43 </td> 40 <td>{$nodes[node].node_id}</td> 44 {* <td>{$nodes[node].node_id}</td> *} 45 <td>{$nodes[node].gw_id}</td> 41 46 <td>{$nodes[node].name}</td> 42 47 <td>
