Merge branch '138-toggle-free-look-with-hotkey' into 'main/atys-live'
[ryzomcore.git] / web / public_php / admin / tool_event_entities.php
blobf5519b724e01acede9c88f4f69d7de728d8d929d
1 <?php
4 // SoniX: yop
5 // SoniX: pour récup les info de view, il faut utiliser la commande getView
6 // SoniX: par ex, sur un AIS : "getView (0x0000000001:15:83:83).NamedEntityState" récupère le state de l'entité specifier
7 // SoniX: "getView *.NamedEntityName" récupère toutes les entité nommé de l'IA sur laquelle tu balance la commande
8 // SoniX: et pour setter une valuer :
9 // SoniX: "getView (0x0000000001:15:83:83).NamedEntityState=1" met le truc à 1
10 // SoniX: En gros, tu récupères les info dans la table variables, et tu vire les 3 premier morceaux (par ex, *.*.AIS.*.NamedEntityName deviens *.NamedEntityName).
11 // SoniX: Par contre, c'est a toi de faire le dispatch sur chaque AIS si besoin.
12 // YoGiN: hum, fun fun fun :D
13 // YoGiN: oki merci beaucoup, je vais voir ca :)
14 // SoniX: j'ai tester sur linuxshard8, d'jon mark a réactivé un morceau d'époside 2 dessus avec 1 variable
15 // YoGiN: d'accord
17 require_once('common.php');
18 require_once('functions_tool_main.php');
19 require_once('functions_tool_event_entities.php');
21 if (!tool_admin_applications_check('tool_event_entities')) nt_common_redirect('index.php');
23 nt_common_add_debug('-- Starting on \'tool_event_entities.php\'');
25 $tpl->assign('tool_title', "Event Entities");
27 $view_domain_id = nt_auth_get_session_var('view_domain_id');
28 $view_shard_id = nt_auth_get_session_var('view_shard_id');
30 if (!$view_domain_id)
32 $view_domain_id = $nel_user['group_default_domain_id'];
33 $view_shard_id = $nel_user['group_default_shard_id'];
34 nt_auth_set_session_var('view_domain_id', $view_domain_id);
35 nt_auth_set_session_var('view_shard_id', $view_shard_id);
38 if (isset($NELTOOL['GET_VARS']['domain']))
40 if ($view_domain_id != $NELTOOL['GET_VARS']['domain'])
42 $view_domain_id = $NELTOOL['GET_VARS']['domain'];
43 nt_auth_set_session_var('view_domain_id', $view_domain_id);
45 $view_shard_id = null;
46 nt_auth_unset_session_var('view_shard_id');
50 if (isset($NELTOOL['GET_VARS']['shard']))
52 $view_shard_id = $NELTOOL['GET_VARS']['shard'];
53 nt_auth_set_session_var('view_shard_id', $view_shard_id);
56 if (isset($NELTOOL['GET_VARS']['refdata']))
58 $tmp_data = unserialize(base64_decode($NELTOOL['GET_VARS']['refdata']));
59 if (is_array($tmp_data))
61 $NELTOOL['POST_VARS'] = $tmp_data;
65 $tpl->assign('tool_domain_list', $nel_user['access']['domains']);
66 $tpl->assign('tool_domain_selected', $view_domain_id);
68 $tpl->assign('tool_shard_list', $nel_user['access']['shards']);
69 $tpl->assign('tool_shard_selected', $view_shard_id);
71 $tool_shard_filters = tool_main_get_shard_ids($view_shard_id);
72 $tpl->assign('tool_shard_filters', $tool_shard_filters);
74 //if (tool_admin_applications_check('tool_player_locator_display_players')) $tpl->assign('restriction_tool_player_locator_display_players', true);
75 //if (tool_admin_applications_check('tool_player_locator_locate')) $tpl->assign('restriction_tool_player_locator_locate', true);
77 if ($view_domain_id)
79 $tool_as_error = null;
81 $AS_Name = tool_main_get_domain_name($view_domain_id);
82 $AS_Host = tool_main_get_domain_host($view_domain_id);
83 $AS_Port = tool_main_get_domain_port($view_domain_id);
84 $AS_ShardName = tool_main_get_shard_name($view_shard_id);
86 $tpl->assign('tool_page_title', 'Event Entities - '. $AS_Name . ($AS_ShardName != '' ? ' / '. $AS_ShardName : ''));
88 $tool_as_error = null;
90 if ($AS_Host && $AS_Port)
92 $adminService = new MyAdminService;
93 if (@$adminService->connect($AS_Host, $AS_Port, $res) === false)
95 nt_common_add_debug($res);
96 $tpl->assign('tool_domain_error', $res );
98 else
100 $tool_services_ee = null;
101 if (isset($NELTOOL['POST_VARS']['services_ee'])) $tool_services_ee = $NELTOOL['POST_VARS']['services_ee'];
102 elseif (isset($NELTOOL['GET_VARS']['services_ee'])) $tool_services_ee = $NELTOOL['GET_VARS']['services_ee'];
104 if ($tool_services_ee)
106 $tpl->assign('tool_post_data', base64_encode(serialize($NELTOOL['POST_VARS'])));
108 switch ($tool_services_ee)
110 case 'update entities':
112 $requested_service_list = $NELTOOL['POST_VARS']['requested_service_list'];
113 $service_list = unserialize(base64_decode($requested_service_list));
115 //nt_common_add_debug($NELTOOL['POST_VARS']);
116 $update_entities = tool_ee_get_entities($NELTOOL['POST_VARS']);
117 nt_common_add_debug('update_entities');
118 nt_common_add_debug($update_entities);
120 reset($update_entities);
121 foreach($update_entities as $entity_data)
123 $service_command = '';
124 $_commands = array();
126 if ($entity_data['entity_state'] != $entity_data['source_entity_state']) $_commands[] = 'NamedEntityState='. $entity_data['entity_state'];
127 if ($entity_data['entity_param1'] != $entity_data['source_entity_param1']) $_commands[] = 'NamedEntityParam1='. $entity_data['entity_param1'];
128 if ($entity_data['entity_param2'] != $entity_data['source_entity_param2']) $_commands[] = 'NamedEntityParam2='. $entity_data['entity_param2'];
130 if (sizeof($_commands) > 0)
132 nt_common_add_debug("something has been updated in entity : ". $entity_data['source_entity']);
133 if (sizeof($_commands) == 1)
135 $service_command = 'getView '. $entity_data['source_entity'] .'.'. $_commands[0];
137 else
139 $service_command = 'getView '. $entity_data['source_entity'] .'.['. implode(',', $_commands) .']';
142 $service = strtolower($entity_data['source_service']);
144 nt_log("Domain '$AS_Name' : '$service_command' on ". $service);
146 $adminService->serviceCmd($service, $service_command);
147 if (!$adminService->waitCallback())
149 nt_common_add_debug('Error while waiting for callback on service \''. $service .'\' for command : '. $service_command);
154 //$requested_service = $NELTOOL['POST_VARS']['source_service'];
155 //$requested_entity = $NELTOOL['POST_VARS']['source_entity'];
156 //$requested_entity_name = $NELTOOL['POST_VARS']['source_entity_name'];
158 //$new_entity_state = $NELTOOL['POST_VARS']['entity_state'];
159 //$new_entity_param1 = $NELTOOL['POST_VARS']['entity_param1'];
160 //$new_entity_param2 = $NELTOOL['POST_VARS']['entity_param2'];
162 //$old_entity_state = $NELTOOL['POST_VARS']['source_entity_state'];
163 //$old_entity_param1 = $NELTOOL['POST_VARS']['source_entity_param1'];
164 //$old_entity_param2 = $NELTOOL['POST_VARS']['source_entity_param2'];
166 //$service_command = '';
168 //$_commands = array();
170 //if ($new_entity_state != $old_entity_state) $_commands[] = 'NamedEntityState='. $new_entity_state;
171 //if ($new_entity_param1 != $old_entity_param1) $_commands[] = 'NamedEntityParam1='. $new_entity_param1;
172 //if ($new_entity_param2 != $old_entity_param2) $_commands[] = 'NamedEntityParam2='. $new_entity_param2;
174 //if (sizeof($_commands) > 0)
176 // nt_common_add_debug("something has been updated in entity : ". $requested_entity);
177 // if (sizeof($_commands) == 1)
178 // {
179 // $service_command = 'getView '. $requested_entity .'.'. $_commands[0];
180 // }
181 // else
182 // {
183 // $service_command = 'getView '. $requested_entity .'.['. implode(',', $_commands) .']';
184 // }
186 // $service = strtolower($requested_service);
188 // nt_log("Domain '$AS_Name' : '$service_command' on ". $service);
190 // $adminService->serviceCmd($service, $service_command);
191 // if (!$adminService->waitCallback())
192 // {
193 // nt_common_add_debug('Error while waiting for callback on service \''. $service .'\' for command : '. $service_command);
194 // }
198 //break;
200 case 'display entities':
202 if (!isset($service_list)) $service_list = tool_main_get_checked_services();
204 if (sizeof($service_list))
206 $service_command = 'getView *.[NamedEntityName,NamedEntityState,NamedEntityParam1,NamedEntityParam2]';
208 nt_log("Domain '$AS_Name' : '$service_command' on ". implode(', ',array_values($service_list)));
210 $tpl->assign('tool_service_select_list', array_combine($service_list, $service_list));
211 $tpl->assign('tool_execute_result', '');
212 $command_return_data = array();
214 reset($service_list);
215 foreach($service_list as $service)
217 //nt_common_add_debug("about to run 'displayPlayers' on '$service' ...");
219 $adminService->serviceCmd($service, $service_command);
220 if (!$adminService->waitCallback())
222 nt_common_add_debug('Error while waiting for callback on service \''. $service .'\' for command : '. $service_command);
224 else
226 // the locator displays a nice output, no need for the raw one
227 //$tpl->assign('tool_execute_command', $service_command);
231 if (sizeof($command_return_data))
233 $entity_data = tool_ee_parse_getview($command_return_data);
234 nt_common_add_debug($entity_data);
235 $tpl->assign('tool_entity_data', $entity_data);
236 $tpl->assign('requested_service_list', base64_encode(serialize($service_list)));
240 break;
244 $status = $adminService->getStates();
245 nt_common_add_debug($status);
247 $domainServices = tool_main_parse_status($status);
249 $filteredServices = array();
250 reset($domainServices);
251 foreach($domainServices as $aKey => $aService)
253 // we are only interested in EGS
254 if ($aService['ShortName'] == 'AIS')
256 $filteredServices[] = $aService;
260 $tpl->assign('tool_services_list', $filteredServices);
265 $tpl->display('tool_event_entities.tpl');