Linux multi-monitor fullscreen support
[ryzomcore.git] / web / public_php / admin / functions_tool_administration.php
blobe65e48a9f43a511bd475226446cea993c1ef1385
1 <?php
3 $tool_admin_menu = array(array('title' => 'Main',
4 'key' => 'help',
5 'uri' => 'tool_administration.php?toolmode=help',
6 'tpl' => 'tool_administration.tpl',
7 'access' => '', // ALWAYS LEAVE EMPTY !
8 ),
9 array('title' => 'Users',
10 'key' => 'users',
11 'uri' => 'tool_administration.php?toolmode=users',
12 'tpl' => 'tool_administration_users.tpl',
13 'access' => 'tool_admin_user',
15 array('title' => 'Groups',
16 'key' => 'groups',
17 'uri' => 'tool_administration.php?toolmode=groups',
18 'tpl' => 'tool_administration_groups.tpl',
19 'access' => 'tool_admin_group',
21 array('title' => 'Restarts',
22 'key' => 'restarts',
23 'uri' => 'tool_administration.php?toolmode=restarts',
24 'tpl' => 'tool_administration_restarts.tpl',
25 'access' => 'tool_admin_restart',
27 array('title' => 'Applications',
28 'key' => 'applications',
29 'uri' => 'tool_administration.php?toolmode=applications',
30 'tpl' => 'tool_administration_applications.tpl',
31 'access' => 'tool_admin_application',
33 array('title' => 'Domains',
34 'key' => 'domains',
35 'uri' => 'tool_administration.php?toolmode=domains',
36 'tpl' => 'tool_administration_domains.tpl',
37 'access' => 'tool_admin_domain',
39 array('title' => 'Shards',
40 'key' => 'shards',
41 'uri' => 'tool_administration.php?toolmode=shards',
42 'tpl' => 'tool_administration_shards.tpl',
43 'access' => 'tool_admin_shard',
45 array('title' => 'Logs',
46 'key' => 'logs',
47 'uri' => 'tool_administration.php?toolmode=logs',
48 'tpl' => 'tool_administration_logs.tpl',
49 'access' => 'tool_admin_logs',
53 $tool_language_list = array(array('lang_id' => 'en',
54 'lang_name' => 'English',
56 array('lang_id' => 'fr',
57 'lang_name' => 'French',
59 array('lang_id' => 'de',
60 'lang_name' => 'German',
64 function tool_admin_menu_get_item_from_key($key)
66 global $tool_admin_menu;
68 reset($tool_admin_menu);
69 foreach($tool_admin_menu as $tool_menu)
71 if ($tool_menu['key'] == $key) return $tool_menu;
74 return null;
77 function tool_admin_users_get_list($group_list)
79 global $db;
81 $data = null;
83 $sql = "SELECT * FROM ". NELDB_USER_TABLE ." ORDER BY user_name ASC";
84 if ($result = $db->sql_query($sql))
86 if ($db->sql_numrows($result))
88 $data = array();
89 while ($row = $db->sql_fetchrow($result))
91 $row['user_group_name'] = tool_admin_groups_get_name_from_id($group_list, $row['user_group_id']);
92 $data[] = $row;
97 return $data;
100 function tool_admin_groups_get_user_list($group_id)
102 global $db;
104 $data = array();
106 $sql = "SELECT * FROM ". NELDB_USER_TABLE ." WHERE user_group_id=". $group_id ." ORDER BY user_name ASC";
107 if ($result = $db->sql_query($sql))
109 if ($db->sql_numrows($result))
111 $data = $db->sql_fetchrowset($result);
115 return $data;
118 function tool_admin_groups_get_list()
120 global $db;
122 $data = null;
124 $sql = "SELECT * FROM ". NELDB_GROUP_TABLE ." ORDER BY group_name ASC";
125 if ($result = $db->sql_query($sql))
127 if ($db->sql_numrows($result))
129 while ($row = $db->sql_fetchrow($result))
131 $row['group_level_name'] = tool_admin_groups_get_level_name_from_id($row['group_level']);
132 $data[] = $row;
137 return $data;
140 function tool_admin_groups_get_level_name_from_id($group_level)
142 global $nel_user_group_levels;
144 reset($nel_user_group_levels);
145 foreach($nel_user_group_levels as $level_data)
147 if ($group_level == $level_data['level_id'])
149 return $level_data['level_name'];
153 return tool_admin_groups_get_level_name_from_id(0);
156 function tool_admin_groups_get_name_from_id($group_list, $group_id)
158 $data = 'unknown';
160 reset($group_list);
161 foreach($group_list as $group_data)
163 if ($group_data['group_id'] == $group_id)
165 $data = $group_data['group_name'];
169 return $data;
172 function tool_admin_users_get_id($user_id)
174 global $db;
176 $data = null;
178 $sql = "SELECT * FROM ". NELDB_USER_TABLE ." WHERE user_id=". $user_id;
179 if ($result = $db->sql_query($sql))
181 if ($db->sql_numrows($result))
183 $data = $db->sql_fetchrow($result);
186 return $data;
189 function tool_admin_users_add($user_name, $user_password, $user_group, $user_active)
191 global $db;
193 $user_name = trim($user_name);
194 $user_password = trim($user_password);
196 if ($user_name == '') return "/!\ Error: user name is empty!";
197 if ($user_password == '') return "/!\ Error: password is empty!";
199 $user_exists = tool_admin_users_name_exist($user_name);
200 if (!$user_exists)
202 $sql = "INSERT INTO ". NELDB_USER_TABLE;
203 $sql .= " (`user_name`,`user_password`,`user_group_id`,`user_created`,`user_active`)";
204 $sql .= " VALUES ";
205 $sql .= " ('". $user_name ."','". md5($user_password) ."','". $user_group ."','". time() ."','". $user_active ."')";
206 $db->sql_query($sql);
207 return "";
210 return "/!\ Error: user name already exists in the database!";
213 function tool_admin_users_name_exist($user_name)
215 global $db;
217 $exists = false;
219 $sql = "SELECT user_id, user_name FROM ". NELDB_USER_TABLE ." WHERE user_name='". $user_name ."'";
220 if ($result = $db->sql_query($sql))
222 if ($db->sql_numrows($result))
224 $exists = true;
228 return $exists;
231 function tool_admin_users_del($user_id)
233 global $db;
235 $sql = "DELETE FROM ". NELDB_USER_TABLE ." WHERE user_id=". $user_id;
236 $db->sql_query($sql);
239 function tool_admin_users_update($user_id, $user_name, $user_password, $user_group, $user_active)
241 global $db;
243 $user_name = trim($user_name);
244 $user_password = trim($user_password);
246 if ($user_name == "") return "/!\ Error: user name is empty!";
247 if (!ereg("^([[:alnum:]]+)$",$user_name)) return "/!\ Error: invalid user name, only alpha numerical characters allowed!";
249 $sql = "SELECT * FROM ". NELDB_USER_TABLE ." WHERE user_name='". $user_name ."' AND user_id<>". $user_id;
250 if ($result = $db->sql_query($sql))
252 if ($db->sql_numrows($result))
254 return "/!\ Error: user name already exists in database!";
258 $sql_ext = "";
259 if ($user_password != '') $sql_ext = ",user_password='". md5($user_password) ."'";
261 $sql = "UPDATE ". NELDB_USER_TABLE ." SET user_name='". $user_name ."',user_group_id='". $user_group ."',user_active='". $user_active ."'". $sql_ext ." WHERE user_id=". $user_id;
262 $db->sql_query($sql);
264 return "";
267 function tool_admin_groups_get_id($group_id)
269 global $db;
271 $data = null;
273 $sql = "SELECT * FROM ". NELDB_GROUP_TABLE ." WHERE group_id=". $group_id;
274 if ($result = $db->sql_query($sql))
276 if ($db->sql_numrows($result))
278 $data = $db->sql_fetchrow($result);
282 return $data;
285 function tool_admin_groups_add($group_name, $group_level, $group_default, $group_active)
287 global $db;
289 $group_name = trim($group_name);
290 if ($group_name == '') return "/!\ Error: group name is empty!";
292 $group_exists = tool_admin_groups_name_exist($group_name);
293 if (!$group_exists)
295 if ($group_default == 1)
297 $sql = "UPDATE ". NELDB_GROUP_TABLE ." SET group_default=0";
298 $db->sql_query($sql);
301 $sql = "INSERT INTO ". NELDB_GROUP_TABLE;
302 $sql .= " (`group_name`,`group_level`,`group_default`,`group_active`) ";
303 $sql .= " VALUES ";
304 $sql .= " ('". $group_name ."',". $group_level .",". $group_default .",". $group_active .")";
305 $db->sql_query($sql);
307 return "";
310 return "/!\ Error: group name already exists in the database!";
313 function tool_admin_groups_name_exist($group_name)
315 global $db;
317 $exists = false;
319 $sql = "SELECT group_id, group_name FROM ". NELDB_GROUP_TABLE ." WHERE group_name='". $group_name ."'";
320 if ($result = $db->sql_query($sql))
322 if ($db->sql_numrows($result))
324 $exists = true;
328 return $exists;
332 function tool_admin_groups_del($group_id)
334 global $db;
336 $sql = "DELETE FROM ". NELDB_GROUP_TABLE ." WHERE group_id=". $group_id;
337 $db->sql_query($sql);
340 function tool_admin_groups_update($group_id, $group_name, $group_level, $group_default, $group_active)
342 global $db;
344 $group_name = trim($group_name);
346 if ($group_name == "") return "/!\ Error: group name is empty!";
347 if (!ereg("^([[:alnum:]]+)$",$group_name)) return "/!\ Error: invalid group name, only alpha numerical characters allowed!";
349 $sql = "SELECT * FROM ". NELDB_GROUP_TABLE ." WHERE group_name='". $group_name ."' AND group_id<>". $group_id;
350 if ($result = $db->sql_query($sql))
352 if ($db->sql_numrows($result))
354 return "/!\ Error: group name already exists in database!";
358 if ($group_default == 1)
360 $sql = "UPDATE ". NELDB_GROUP_TABLE ." SET group_default=0";
361 $db->sql_query($sql);
364 $sql = "UPDATE ". NELDB_GROUP_TABLE ." SET group_name='". $group_name ."',group_level='". $group_level ."',group_default='". $group_default ."',group_active='". $group_active ."' WHERE group_id=". $group_id;
365 $db->sql_query($sql);
367 return "";
370 function tool_admin_groups_update_default_domain($group_id, $domain_id)
372 global $db;
374 $sql = "SELECT * FROM ". NELDB_GROUP_TABLE ." WHERE group_id=". $group_id;
375 if ($result = $db->sql_query($sql))
377 if ($db->sql_numrows($result))
379 $row = $db->sql_fetchrow($result);
381 if ($row['group_default_domain_id'] != $domain_id)
383 $sql = "UPDATE ". NELDB_GROUP_TABLE ." SET group_default_domain_id=". $domain_id .",group_default_shard_id=0 WHERE group_id=". $group_id;
384 $db->sql_query($sql);
387 else
389 return "/!\ Error: invalid group id!";
393 return "";
396 function tool_admin_groups_update_default_shard($group_id, $shard_id)
398 global $db;
400 $sql = "SELECT * FROM ". NELDB_GROUP_TABLE ." WHERE group_id=". $group_id;
401 if ($result = $db->sql_query($sql))
403 if ($db->sql_numrows($result))
405 $sql = "UPDATE ". NELDB_GROUP_TABLE ." SET group_default_shard_id=". $shard_id ." WHERE group_id=". $group_id;
406 $db->sql_query($sql);
408 else
410 return "/!\ Error: invalid group id!";
414 return "";
417 function tool_admin_groups_update_default_application($group_id, $application_id)
419 global $db;
421 $sql = "SELECT * FROM ". NELDB_GROUP_TABLE ." WHERE group_id=". $group_id;
422 if ($result = $db->sql_query($sql))
424 if ($db->sql_numrows($result))
426 $sql = "UPDATE ". NELDB_GROUP_TABLE ." SET group_default_application_id=". $application_id ." WHERE group_id=". $group_id;
427 $db->sql_query($sql);
429 else
431 return "/!\ Error: invalid group id!";
435 return "";
439 function tool_admin_applications_get_list()
441 global $db;
443 $data = null;
445 $sql = "SELECT * FROM ". NELDB_APPLICATION_TABLE ." ORDER BY application_order ASC, application_name ASC";
446 if ($result = $db->sql_query($sql))
448 if ($db->sql_numrows($result))
450 $data = $db->sql_fetchrowset($result);
454 return $data;
457 function tool_admin_applications_get_id($application_id)
459 global $db;
461 $data = null;
463 $sql = "SELECT * FROM ". NELDB_APPLICATION_TABLE ." WHERE application_id=". $application_id;
464 if ($result = $db->sql_query($sql))
466 if ($db->sql_numrows($result))
468 $data = $db->sql_fetchrow($result);
472 return $data;
475 function tool_admin_applications_add($application_name, $application_uri, $application_restriction, $application_icon, $application_order, $application_visible)
477 global $db;
479 $application_name = trim($application_name);
480 if ($application_name == '') return "/!\ Error: application name is empty!";
482 $application_exists = tool_admin_applications_name_exist($application_name);
483 if (!$application_exists)
485 $sql = "INSERT INTO ". NELDB_APPLICATION_TABLE;
486 $sql .= " (`application_name`,`application_uri`,`application_restriction`,`application_order`,`application_visible`,`application_icon`) ";
487 $sql .= " VALUES ";
488 $sql .= " ('". $application_name ."','". $application_uri ."','". $application_restriction ."','". $application_order ."','". $application_visible ."','". $application_icon ."')";
489 $db->sql_query($sql);
491 return "";
494 return "/!\ Error: application name already exists in the database!";
497 function tool_admin_applications_name_exist($application_name)
499 global $db;
501 $exists = false;
503 $sql = "SELECT application_id, application_name FROM ". NELDB_APPLICATION_TABLE ." WHERE application_name='". $application_name ."'";
504 if ($result = $db->sql_query($sql))
506 if ($db->sql_numrows($result))
508 $exists = true;
512 return $exists;
515 function tool_admin_applications_del($application_id)
517 global $db;
519 $sql = "DELETE FROM ". NELDB_USER_APPLICATION_TABLE ." WHERE user_application_application_id=". $application_id;
520 $db->sql_query($sql);
522 $sql = "DELETE FROM ". NELDB_GROUP_APPLICATION_TABLE ." WHERE group_application_application_id=". $application_id;
523 $db->sql_query($sql);
525 $sql = "DELETE FROM ". NELDB_APPLICATION_TABLE ." WHERE application_id=". $application_id;
526 $db->sql_query($sql);
529 function tool_admin_applications_update($application_id, $application_name, $application_uri, $application_restriction, $application_icon, $application_order, $application_visible)
531 global $db;
533 $application_name = trim($application_name);
534 if ($application_name == "") return "/!\ Error: application name is empty!";
536 $sql = "SELECT * FROM ". NELDB_APPLICATION_TABLE ." WHERE application_name='". $application_name ."' AND application_id<>". $application_id;
537 if ($result = $db->sql_query($sql))
539 if ($db->sql_numrows($result))
541 return "/!\ Error: application name already exists in database!";
545 $sql = "UPDATE ". NELDB_APPLICATION_TABLE ." SET application_name='". $application_name ."',application_uri='". $application_uri ."',application_restriction='". $application_restriction ."',application_icon='". $application_icon ."',application_order='". $application_order ."',application_visible='". $application_visible ."' WHERE application_id=". $application_id;
546 $db->sql_query($sql);
548 return "";
551 function tool_admin_domains_get_list()
553 global $db;
555 $data = null;
557 $sql = "SELECT * FROM ". NELDB_DOMAIN_TABLE ." ORDER BY domain_name ASC";
558 if ($result = $db->sql_query($sql))
560 if ($db->sql_numrows($result))
562 $data = $db->sql_fetchrowset($result);
566 return $data;
569 function tool_admin_domains_add($domain_name, $domain_application, $domain_as_host, $domain_as_port, $domain_rrd_path, $domain_las_admin_path, $domain_las_local_path, $domain_sql_string, $domain_cs_sql_string, $domain_hd_check, $domain_mfs_web)
571 global $db;
573 $domain_name = trim($domain_name);
574 if ($domain_name == '') return "/!\ Error: domain name is empty!";
576 $domain_exists = tool_admin_domains_name_exist($domain_name);
577 if (!$domain_exists)
579 $sql = "INSERT INTO ". NELDB_DOMAIN_TABLE;
580 $sql .= " (`domain_name`,`domain_application`,`domain_as_host`,`domain_as_port`,`domain_rrd_path`,`domain_las_admin_path`,`domain_las_local_path`,`domain_sql_string`,`domain_hd_check`,`domain_mfs_web`,`domain_cs_sql_string`) ";
581 $sql .= " VALUES ";
582 $sql .= " ('". $domain_name ."','". $domain_application ."','". $domain_as_host ."','". $domain_as_port ."','". $domain_rrd_path ."','". $domain_las_admin_path ."','". $domain_las_local_path ."','". $domain_sql_string ."',". $domain_hd_check .",'". $domain_mfs_web ."','". $domain_cs_sql_string ."') ";
583 $db->sql_query($sql);
585 return "";
588 return "/!\ Error: domain name already exists in the database!";
591 function tool_admin_domains_name_exist($domain_name)
593 global $db;
595 $exists = false;
597 $sql = "SELECT domain_id, domain_name FROM ". NELDB_DOMAIN_TABLE ." WHERE domain_name='". $domain_name ."'";
598 if ($result = $db->sql_query($sql))
600 if ($db->sql_numrows($result))
602 $exists = true;
606 return $exists;
609 function tool_admin_domains_get_id($domain_id)
611 global $db;
613 $data = null;
615 $sql = "SELECT * FROM ". NELDB_DOMAIN_TABLE ." WHERE domain_id=". $domain_id;
616 if ($result = $db->sql_query($sql))
618 if ($db->sql_numrows($result))
620 $data = $db->sql_fetchrow($result);
624 return $data;
627 function tool_admin_domains_del($domain_id)
629 global $db;
631 $sql = "DELETE FROM ". NELDB_USER_SHARD_TABLE ." WHERE user_shard_domain_id=". $domain_id;
632 $db->sql_query($sql);
634 $sql = "DELETE FROM ". NELDB_USER_DOMAIN_TABLE ." WHERE user_domain_domain_id=". $domain_id;
635 $db->sql_query($sql);
637 $sql = "DELETE FROM ". NELDB_GROUP_SHARD_TABLE ." WHERE group_shard_domain_id=". $domain_id;
638 $db->sql_query($sql);
640 $sql = "DELETE FROM ". NELDB_GROUP_DOMAIN_TABLE ." WHERE group_domain_domain_id=". $domain_id;
641 $db->sql_query($sql);
643 $sql = "DELETE FROM ". NELDB_SHARD_TABLE ." WHERE shard_domain_id=". $domain_id;
644 $db->sql_query($sql);
646 $sql = "DELETE FROM ". NELDB_DOMAIN_TABLE ." WHERE domain_id=". $domain_id;
647 $db->sql_query($sql);
651 function tool_admin_domains_update($domain_id, $domain_name, $domain_application, $domain_as_host, $domain_as_port, $domain_rrd_path, $domain_las_admin_path, $domain_las_local_path, $domain_sql_string, $domain_cs_sql_string, $domain_hd_check, $domain_mfs_web)
653 global $db;
655 $domain_name = trim($domain_name);
657 if ($domain_name == "") return "/!\ Error: domain name is empty!";
659 $sql = "SELECT * FROM ". NELDB_DOMAIN_TABLE ." WHERE domain_name='". $domain_name ."' AND domain_id<>". $domain_id;
660 if ($result = $db->sql_query($sql))
662 if ($db->sql_numrows($result))
664 return "/!\ Error: domain name already exists in database!";
668 $sql = "UPDATE ". NELDB_DOMAIN_TABLE ." SET domain_name='". $domain_name."',domain_application='". $domain_application ."',domain_as_host='". $domain_as_host ."',domain_as_port='". $domain_as_port ."',domain_rrd_path='". $domain_rrd_path ."',domain_las_admin_path='". $domain_las_admin_path ."',domain_las_local_path='". $domain_las_local_path ."',domain_sql_string='". $domain_sql_string ."',domain_hd_check=". $domain_hd_check .",domain_mfs_web='". $domain_mfs_web ."',domain_cs_sql_string='". $domain_cs_sql_string ."' WHERE domain_id=". $domain_id;
669 $db->sql_query($sql);
671 return "";
674 function tool_admin_shards_get_list()
676 global $db;
678 $data = null;
680 $sql = "SELECT * FROM ". NELDB_SHARD_TABLE ." LEFT JOIN ". NELDB_DOMAIN_TABLE ." ON (shard_domain_id=domain_id) ORDER BY domain_name ASC, shard_name ASC";
681 if ($result = $db->sql_query($sql))
683 if ($db->sql_numrows($result))
685 $data = $db->sql_fetchrowset($result);
689 return $data;
692 function tool_admin_shards_add($shard_name, $shard_as_id, $shard_domain_id, $shard_language)
694 global $db;
696 $shard_name = trim($shard_name);
697 if ($shard_name == '') return "/!\ Error: shard name is empty!";
699 $shard_as_id = trim($shard_as_id);
700 //if (!is_numeric($shard_as_id)) return "/!\ Error: shard AS Id is invalid!";
702 //$shard_exists = tool_admin_shards_name_exist($shard_as_id);
703 //if (!$shard_exists)
705 $sql = "INSERT INTO ". NELDB_SHARD_TABLE;
706 $sql .= " (`shard_name`,`shard_as_id`,`shard_domain_id`,`shard_lang`) ";
707 $sql .= " VALUES ";
708 $sql .= " ('". $shard_name ."','". $shard_as_id ."','". $shard_domain_id ."','". $shard_language ."') ";
709 $db->sql_query($sql);
710 return "";
713 //return "/!\ Error: shard AS Id already exists in the database!";
716 function tool_admin_shards_name_exist($shard_as_id, $except_id=false)
718 global $db;
720 if ($shard_as_id == '*' || $shard_as_id == '?') return false;
722 $exists = false;
724 $sql = "SELECT * FROM ". NELDB_SHARD_TABLE ." WHERE shard_as_id='". $shard_as_id ."'";
725 if ($except_id !== false) $sql .= " AND shard_id<>". $except_id;
727 if ($result = $db->sql_query($sql))
729 if ($db->sql_numrows($result))
731 $exists = true;
735 return $exists;
738 function tool_admin_shards_get_id($shard_id)
740 global $db;
742 $data = null;
744 $sql = "SELECT * FROM ". NELDB_SHARD_TABLE ." WHERE shard_id=". $shard_id;
745 if ($result = $db->sql_query($sql))
747 if ($db->sql_numrows($result))
749 $data = $db->sql_fetchrow($result);
753 return $data;
756 function tool_admin_shards_del($shard_id)
758 global $db;
760 $sql = "DELETE FROM ". NELDB_USER_SHARD_TABLE ." WHERE user_shard_shard_id=". $shard_id;
761 $db->sql_query($sql);
763 $sql = "DELETE FROM ". NELDB_GROUP_SHARD_TABLE ." WHERE group_shard_shard_id=". $shard_id;
764 $db->sql_query($sql);
766 $sql = "DELETE FROM ". NELDB_SHARD_TABLE ." WHERE shard_id=". $shard_id;
767 $db->sql_query($sql);
770 function tool_admin_shards_update($shard_id, $shard_name, $shard_as_id, $shard_domain_id, $shard_language)
772 global $db;
774 $shard_name = trim($shard_name);
775 if ($shard_name == '') return "/!\ Error: shard name is empty!";
777 $shard_as_id = trim($shard_as_id);
778 //if (!is_numeric($shard_as_id)) return "/!\ Error: shard AS Id is invalid!";
780 //$shard_exists = tool_admin_shards_name_exist($shard_as_id, $shard_id);
781 //if (!$shard_exists)
783 $sql = "UPDATE ". NELDB_SHARD_TABLE ." SET shard_name='". $shard_name ."',shard_as_id='". $shard_as_id ."',shard_domain_id='". $shard_domain_id ."',shard_lang='". $shard_language ."' WHERE shard_id=". $shard_id;
784 $db->sql_query($sql);
786 return "";
789 //return "/!\ Error: shard AS Id already exists in the database!";
794 function tool_admin_users_domains_update($user_id, $group_id, $domain_ids)
796 global $db;
798 $user_domains = tool_admin_users_domains_get_list($user_id, true);
799 $group_domains = tool_admin_groups_domains_get_list($group_id, true);
801 $sql = "DELETE FROM ". NELDB_USER_DOMAIN_TABLE ." WHERE user_domain_user_id=". $user_id;
802 $db->sql_query($sql);
804 if (is_array($domain_ids) and sizeof($domain_ids))
806 reset($domain_ids);
807 foreach($domain_ids as $domain_id)
809 if (is_numeric($domain_id) && $domain_id > 0)
811 $sql = "INSERT INTO ". NELDB_USER_DOMAIN_TABLE ." (`user_domain_user_id`,`user_domain_domain_id`) VALUES ('". $user_id ."','". $domain_id ."')";
812 $db->sql_query($sql);
817 // now we remove all shards except those that belong to the user AND group
819 $sql = "DELETE FROM ". NELDB_USER_SHARD_TABLE ." WHERE user_shard_user_id=". $user_id;
820 if (is_array($domain_ids) && sizeof($domain_ids)) $sql .= " AND user_shard_domain_id NOT IN (". implode(',',array_values($domain_ids)) .")";
821 if (is_array($group_domains) && sizeof($group_domains)) $sql .= " AND user_shard_domain_id NOT IN (". implode(',',array_values($group_domains)) .")";
822 $db->sql_query($sql);
825 function tool_admin_users_domains_get_list($user_id, $compact = false)
827 global $db;
829 $data = array();
830 $data1 = array();
832 $sql = "SELECT * FROM ". NELDB_USER_DOMAIN_TABLE ." LEFT JOIN ". NELDB_DOMAIN_TABLE ." ON (user_domain_domain_id=domain_id) WHERE user_domain_user_id=". $user_id ." ORDER BY domain_name ASC";
833 if ($result = $db->sql_query($sql))
835 if ($db->sql_numrows($result))
837 $data1 = $db->sql_fetchrowset($result);
841 if ($compact)
843 reset($data1);
844 foreach($data1 as $data_tmp)
846 $data[] = $data_tmp['user_domain_domain_id'];
849 else
851 $data = $data1;
856 return $data;
859 function tool_admin_groups_domains_get_list($group_id, $compact = false)
861 global $db;
863 $data = array();
864 $data1 = array();
866 $sql = "SELECT * FROM ". NELDB_GROUP_DOMAIN_TABLE ." LEFT JOIN ". NELDB_DOMAIN_TABLE ." ON (group_domain_domain_id=domain_id) WHERE group_domain_group_id=". $group_id ." ORDER BY domain_name ASC";
867 if ($result = $db->sql_query($sql))
869 if ($db->sql_numrows($result))
871 $data1 = $db->sql_fetchrowset($result);
875 if ($compact)
877 reset($data1);
878 foreach($data1 as $data_tmp)
880 $data[] = $data_tmp['group_domain_domain_id'];
883 else
885 $data = $data1;
888 //nt_common_add_debug($data);
890 return $data;
893 function tool_admin_users_domains_merge($domain_list, $user_list, $group_list)
895 $data = array();
897 if (is_array($domain_list) && sizeof($domain_list))
899 reset($domain_list);
900 foreach($domain_list as $domain)
902 if (in_array($domain['domain_id'], $group_list))
904 $domain['domain_disabled'] = true;
905 $domain['domain_visible'] = true;
907 elseif (in_array($domain['domain_id'], $user_list))
909 $domain['domain_selected'] = true;
910 $domain['domain_visible'] = true;
913 $data[] = $domain;
917 return $data;
920 function tool_admin_users_shards_get_list($user_id, $compact = false)
922 global $db;
924 $data = array();
925 $data1 = array();
927 $sql = "SELECT * FROM ". NELDB_USER_SHARD_TABLE ." LEFT JOIN ". NELDB_SHARD_TABLE ." ON (user_shard_shard_id=shard_id) WHERE user_shard_user_id=". $user_id ." ORDER BY shard_name ASC";
928 if ($result = $db->sql_query($sql))
930 if ($db->sql_numrows($result))
932 $data1 = $db->sql_fetchrowset($result);
936 if ($compact)
938 reset($data1);
939 foreach($data1 as $data_tmp)
941 $data[] = $data_tmp['user_shard_shard_id'];
944 else
946 $data = $data1;
951 return $data;
954 function tool_admin_groups_shards_get_list($group_id, $compact = false)
956 global $db;
958 $data = array();
959 $data1 = array();
961 $sql = "SELECT * FROM ". NELDB_GROUP_SHARD_TABLE ." LEFT JOIN ". NELDB_SHARD_TABLE ." ON (group_shard_shard_id=shard_id) WHERE group_shard_group_id=". $group_id ." ORDER BY shard_name ASC";
962 if ($result = $db->sql_query($sql))
964 if ($db->sql_numrows($result))
966 $data1 = $db->sql_fetchrowset($result);
970 if ($compact)
972 reset($data1);
973 foreach($data1 as $data_tmp)
975 $data[] = $data_tmp['group_shard_shard_id'];
978 else
980 $data = $data1;
983 return $data;
986 function tool_admin_users_shards_merge($domain_list, $shard_list, $user_list, $group_list)
988 $data1 = array();
990 if (is_array($shard_list) && sizeof($shard_list))
992 reset($shard_list);
993 foreach($shard_list as $shard)
995 if (in_array($shard['shard_id'], $group_list))
997 $shard['shard_disabled'] = true;
999 elseif (in_array($shard['shard_id'], $user_list))
1001 $shard['shard_selected'] = true;
1004 $data1[] = $shard;
1007 $shard_list = $data1;
1010 $data2 = array();
1012 // now we sort the shards by their domain
1013 if (is_array($domain_list) && sizeof($domain_list))
1015 reset($domain_list);
1016 foreach($domain_list as $domain)
1018 // looks for the shards that belong to this domain
1019 reset($shard_list);
1020 foreach($shard_list as $shard)
1022 if ($domain['domain_id'] == $shard['shard_domain_id'])
1024 $domain['shard_list'][] = $shard;
1028 $data2[] = $domain;
1031 $domain_list = $data2;
1034 return $domain_list;
1037 function tool_admin_users_shards_update($user_id, $group_id, $shard_ids)
1039 global $db;
1041 $sql = "DELETE FROM ". NELDB_USER_SHARD_TABLE ." WHERE user_shard_user_id=". $user_id;
1042 $db->sql_query($sql);
1044 if (is_array($shard_ids) && sizeof($shard_ids))
1046 reset($shard_ids);
1047 foreach($shard_ids as $shard_tmp)
1049 $tmp = explode('_', $shard_tmp);
1050 $domain_id = $tmp[0];
1051 $shard_id = $tmp[1];
1053 if (is_numeric($domain_id) && is_numeric($shard_id) && $domain_id > 0 && $shard_id > 0)
1055 $sql = "INSERT INTO ". NELDB_USER_SHARD_TABLE ." (`user_shard_user_id`,`user_shard_shard_id`,`user_shard_domain_id`) VALUES ('". $user_id ."','". $shard_id ."','". $domain_id ."')";
1056 $db->sql_query($sql);
1062 function tool_admin_groups_domains_update($group_id, $domain_ids)
1064 global $db;
1066 $sql = "DELETE FROM ". NELDB_GROUP_DOMAIN_TABLE ." WHERE group_domain_group_id=". $group_id;
1067 $db->sql_query($sql);
1069 if (is_array($domain_ids) and sizeof($domain_ids))
1071 reset($domain_ids);
1072 foreach($domain_ids as $domain_id)
1074 if (is_numeric($domain_id) && $domain_id > 0)
1076 $sql = "INSERT INTO ". NELDB_GROUP_DOMAIN_TABLE ." (`group_domain_group_id`,`group_domain_domain_id`) VALUES ('". $group_id ."','". $domain_id ."')";
1077 $db->sql_query($sql);
1082 $sql = "DELETE FROM ". NELDB_GROUP_SHARD_TABLE ." WHERE group_shard_group_id=". $group_id;
1083 if (is_array($domain_ids) && sizeof($domain_ids)) $sql .= " AND group_shard_domain_id NOT IN (". implode(',',array_values($domain_ids)) .")";
1084 $db->sql_query($sql);
1086 // we need to check some stuff for each user in this group
1088 // first we get the list of users that belong to his group
1089 $sql = "SELECT * FROM ". NELDB_USER_TABLE ." WHERE user_group_id=". $group_id;
1090 if ($result = $db->sql_query($sql))
1092 if ($db->sql_numrows($result))
1094 while ($row = $db->sql_fetchrow($result))
1096 // get a user
1097 $user_id = $row['user_id'];
1099 // get the domains specific to the user
1100 $user_domain_list = tool_admin_users_domains_get_list($user_id, true);
1102 // then we delete the shard that don't belong to the group nor user
1103 $sql = "DELETE FROM ". NELDB_USER_SHARD_TABLE ." WHERE user_shard_user_id=". $user_id;
1104 if (is_array($domain_ids) && sizeof($domain_ids)) $sql .= " AND user_shard_domain_id NOT IN (". implode(',', array_values($domain_ids)) .")";
1105 if (is_array($user_domain_list) && sizeof($user_domain_list)) $sql .= " AND user_shard_domain_id NOT IN (". implode(',', array_values($user_domain_list)) .")";
1106 $db->sql_query($sql);
1108 // make sure users don't have a domain that already belongs to a group
1109 $sql = "DELETE FROM ". NELDB_USER_DOMAIN_TABLE ." WHERE user_domain_user_id=". $user_id;
1110 if (is_array($domain_ids) && sizeof($domain_ids)) $sql .= " AND user_domain_domain_id IN (". implode(',', array_values($domain_ids)) .")";
1111 $db->sql_query($sql);
1118 function tool_admin_groups_domains_merge($domain_list, $group_list)
1120 $data = array();
1122 if (is_array($domain_list) && sizeof($domain_list))
1124 reset($domain_list);
1125 foreach($domain_list as $domain)
1127 if (in_array($domain['domain_id'], $group_list))
1129 $domain['domain_visible'] = true;
1130 $domain['domain_selected'] = true;
1133 $data[] = $domain;
1137 return $data;
1140 function tool_admin_groups_shards_merge($domain_list, $shard_list, $group_list)
1142 $data1 = array();
1144 if (is_array($shard_list) && sizeof($shard_list))
1146 reset($shard_list);
1147 foreach($shard_list as $shard)
1149 if (in_array($shard['shard_id'], $group_list))
1151 $shard['shard_selected'] = true;
1154 $data1[] = $shard;
1157 $shard_list = $data1;
1160 $data2 = array();
1162 // now we sort the shards by their domain
1163 if (is_array($domain_list) && sizeof($domain_list) && is_array($shard_list) && sizeof($shard_list))
1165 reset($domain_list);
1166 foreach($domain_list as $domain)
1168 // looks for the shards that belong to this domain
1169 reset($shard_list);
1170 foreach($shard_list as $shard)
1172 if ($domain['domain_id'] == $shard['shard_domain_id'])
1174 $domain['shard_list'][] = $shard;
1178 $data2[] = $domain;
1181 $domain_list = $data2;
1184 return $domain_list;
1187 function tool_admin_groups_shards_update($group_id, $shard_ids)
1189 global $db;
1191 $sql = "DELETE FROM ". NELDB_GROUP_SHARD_TABLE ." WHERE group_shard_group_id=". $group_id;
1192 $db->sql_query($sql);
1194 if (is_array($shard_ids) && sizeof($shard_ids))
1196 $user_shard_ids = array();
1198 reset($shard_ids);
1199 foreach($shard_ids as $shard_tmp)
1201 $tmp = explode('_', $shard_tmp);
1202 $domain_id = $tmp[0];
1203 $shard_id = $tmp[1];
1205 $group_shard_ids[] = $shard_id;
1207 if (is_numeric($domain_id) && is_numeric($shard_id) && $domain_id > 0 && $shard_id > 0)
1209 $sql = "INSERT INTO ". NELDB_GROUP_SHARD_TABLE ." (`group_shard_group_id`,`group_shard_shard_id`,`group_shard_domain_id`) VALUES ('". $group_id ."','". $shard_id ."','". $domain_id ."')";
1210 $db->sql_query($sql);
1214 // we need to check some stuff for each user in this group
1216 // first we get the list of users that belong to his group
1217 $sql = "SELECT * FROM ". NELDB_USER_TABLE ." WHERE user_group_id=". $group_id;
1218 if ($result = $db->sql_query($sql))
1220 if ($db->sql_numrows($result))
1222 while ($row = $db->sql_fetchrow($result))
1224 // get a user
1225 $user_ids[] = $row['user_id'];
1228 $sql = "DELETE FROM ". NELDB_USER_SHARD_TABLE ." WHERE user_shard_user_id IN (". implode(',',array_values($user_ids)) .") AND user_shard_shard_id IN (". implode(',', array_values($group_shard_ids)) .")";
1229 $db->sql_query($sql);
1236 function tool_admin_groups_applications_update($group_id, $application_ids)
1238 global $db;
1240 $sql = "DELETE FROM ". NELDB_GROUP_APPLICATION_TABLE ." WHERE group_application_group_id=". $group_id;
1241 $db->sql_query($sql);
1243 if (is_array($application_ids) && sizeof($application_ids))
1245 reset($application_ids);
1246 foreach($application_ids as $application_id)
1248 $sql = "INSERT INTO ". NELDB_GROUP_APPLICATION_TABLE ." (`group_application_group_id`,`group_application_application_id`) VALUES ('". $group_id ."','". $application_id ."')";
1249 $db->sql_query($sql);
1252 // we need to make sure no user in this group has this application
1253 $sql = "SELECT * FROM ". NELDB_USER_TABLE ." WHERE user_group_id=". $group_id;
1254 if ($result = $db->sql_query($sql))
1256 if ($db->sql_numrows($result))
1258 while ($row = $db->sql_fetchrow($result))
1260 // get a user
1261 $user_ids[] = $row['user_id'];
1264 $sql = "DELETE FROM ". NELDB_USER_APPLICATION_TABLE ." WHERE user_application_user_id IN (". implode(',',array_values($user_ids)) .") AND user_application_application_id IN (". implode(',', array_values($application_ids)) .")";
1265 $db->sql_query($sql);
1273 function tool_admin_groups_applications_get_list($group_id, $compact = false)
1275 global $db;
1277 $data = array();
1278 $data1 = array();
1280 $sql = "SELECT * FROM ". NELDB_GROUP_APPLICATION_TABLE ." LEFT JOIN ". NELDB_APPLICATION_TABLE ." ON (group_application_application_id=application_id) WHERE group_application_group_id=". $group_id;
1281 if ($result = $db->sql_query($sql))
1283 if ($db->sql_numrows($result))
1285 $data1 = $db->sql_fetchrowset($result);
1289 if ($compact)
1291 reset($data1);
1292 foreach($data1 as $data_tmp)
1294 $data[] = $data_tmp['group_application_application_id'];
1297 else
1299 $data = $data1;
1302 return $data;
1305 function tool_admin_groups_applications_merge($appl_list, $group_list)
1307 $data1 = array();
1309 if (is_array($appl_list) && sizeof($appl_list))
1311 reset($appl_list);
1312 foreach($appl_list as $appl)
1314 if (in_array($appl['application_id'], $group_list))
1316 $appl['application_selected'] = true;
1319 $data1[] = $appl;
1322 $appl_list = $data1;
1325 return $appl_list;
1328 function tool_admin_users_applications_get_list($user_id, $compact = false)
1330 global $db;
1332 $data = array();
1333 $data1 = array();
1335 $sql = "SELECT * FROM ". NELDB_USER_APPLICATION_TABLE ." LEFT JOIN ". NELDB_APPLICATION_TABLE ." ON (user_application_application_id=application_id) WHERE user_application_user_id=". $user_id;
1336 if ($result = $db->sql_query($sql))
1338 if ($db->sql_numrows($result))
1340 $data1 = $db->sql_fetchrowset($result);
1344 if ($compact)
1346 reset($data1);
1347 foreach($data1 as $data_tmp)
1349 $data[] = $data_tmp['user_application_application_id'];
1352 else
1354 $data = $data1;
1357 return $data;
1360 function tool_admin_users_applications_merge($appl_list, $user_list, $group_list)
1362 $data1 = array();
1364 if (is_array($appl_list) && sizeof($appl_list))
1366 reset($appl_list);
1367 foreach($appl_list as $appl)
1369 if (in_array($appl['application_id'], $group_list))
1371 $appl['application_disabled'] = true;
1373 elseif (in_array($appl['application_id'], $user_list))
1375 $appl['application_selected'] = true;
1378 $data1[] = $appl;
1381 $appl_list = $data1;
1384 return $appl_list;
1387 function tool_admin_users_applications_update($user_id, $application_ids)
1389 global $db;
1391 $sql = "DELETE FROM ". NELDB_USER_APPLICATION_TABLE ." WHERE user_application_user_id=". $user_id;
1392 $db->sql_query($sql);
1394 if (is_array($application_ids) && sizeof($application_ids))
1396 reset($application_ids);
1397 foreach($application_ids as $application_id)
1399 if (is_numeric($application_id) && $application_id > 0)
1401 $sql = "INSERT INTO ". NELDB_USER_APPLICATION_TABLE ." (`user_application_user_id`,`user_application_application_id`) VALUES ('". $user_id ."','". $application_id ."')";
1402 $db->sql_query($sql);
1408 function tool_admin_applications_build_menu_list($user_access)
1410 $menu = array();
1412 // return $user_access['applications'];
1414 if (is_array($user_access['applications']) && sizeof($user_access['applications']))
1416 reset($user_access['applications']);
1417 foreach($user_access['applications'] as $appl_data)
1419 if ($appl_data['application_visible'] == 1)
1421 $user_check = tool_admin_applications_build_menu_check($appl_data['application_id'], $user_access['user_applications'], 'user_application_application_id');
1422 $group_check = tool_admin_applications_build_menu_check($appl_data['application_id'], $user_access['group_applications'], 'group_application_application_id');
1424 if ($appl_data['application_restriction'] == '')
1426 $menu[] = $appl_data;
1428 elseif ($user_check || $group_check)
1430 $menu[] = $appl_data;
1436 return $menu;
1439 function tool_admin_applications_get_default($data, $application_id)
1441 if (is_array($data) && sizeof($data))
1443 reset($data);
1444 foreach($data as $dt)
1446 if ($dt['application_id'] == $application_id)
1448 return $dt;
1452 return false;
1455 function tool_admin_applications_build_menu_check($appl_id, $data, $data_name)
1457 if (is_array($data) && sizeof($data))
1459 reset($data);
1460 foreach($data as $dt)
1462 if ($dt[$data_name] == $appl_id)
1464 return true;
1469 return false;
1472 function tool_admin_applications_check($appl)
1474 global $nel_user;
1476 $ua = $nel_user['access']['user_applications'];
1477 $ga = $nel_user['access']['group_applications'];
1479 if (is_array($ua) && sizeof($ua))
1481 reset($ua);
1482 foreach($ua as $a)
1484 if ($a['application_restriction'] == $appl)
1486 return true;
1491 if (is_array($ga) && sizeof($ga))
1493 reset($ga);
1494 foreach($ga as $a)
1496 if ($a['application_restriction'] == $appl)
1498 return true;
1503 return false;
1506 function tool_admin_menu_get_list($ie)
1508 global $tool_admin_menu;
1509 global $nel_user;
1511 $new_menu = array();
1513 reset($tool_admin_menu);
1514 foreach($tool_admin_menu as $menu_item)
1516 if (($menu_item['access'] == '') || tool_admin_applications_check($menu_item['access']))
1518 if ($ie === false)
1520 $new_menu[] = $menu_item;
1525 return $new_menu;
1528 function tool_admin_users_groups_domains_merge()
1530 global $nel_user;
1532 $user_domains = array();
1534 $ud = $nel_user['access']['user_domains'];
1535 $gd = $nel_user['access']['group_domains'];
1537 $dd = tool_admin_domains_get_list();
1539 if (is_array($dd) && sizeof($dd))
1541 reset($dd);
1542 foreach($dd as $domain_item)
1544 if (is_array($ud))
1546 reset($ud);
1547 foreach($ud as $udomain)
1549 if ($domain_item['domain_id'] == $udomain['domain_id'])
1551 $user_domains[] = $domain_item;
1556 if (is_array($gd))
1558 reset($gd);
1559 foreach($gd as $gdomain)
1561 if ($domain_item['domain_id'] == $gdomain['domain_id'])
1563 $user_domains[] = $domain_item;
1570 return $user_domains;
1573 function tool_admin_users_groups_shards_merge()
1575 global $nel_user;
1577 $user_shards = array();
1579 $us = $nel_user['access']['user_shards'];
1580 $gs = $nel_user['access']['group_shards'];
1582 $ss = tool_admin_shards_get_list();
1584 if (is_array($ss) && sizeof($ss))
1586 reset($ss);
1587 foreach($ss as $shard_item)
1589 if (is_array($us))
1591 reset($us);
1592 foreach($us as $ushard)
1594 if ($shard_item['shard_id'] == $ushard['shard_id'])
1596 $user_shards[] = $shard_item;
1601 if (is_array($gs))
1603 reset($gs);
1604 foreach($gs as $gshard)
1606 if ($shard_item['shard_id'] == $gshard['shard_id'])
1608 $user_shards[] = $shard_item;
1615 return $user_shards;
1618 function tool_admin_logs_get_count()
1620 global $db;
1622 $total = 0;
1624 $sql = "SELECT * FROM ". NELDB_LOG_TABLE;
1625 if ($result = $db->sql_query($sql))
1627 $total = $db->sql_numrows($result);
1630 return $total;
1633 function tool_admin_logs_get_list($start=0,$limit=25)
1635 global $db;
1637 $data = array();
1639 $sql = "SELECT * FROM ". NELDB_LOG_TABLE ." ORDER BY logs_id DESC LIMIT ". $start .",". $limit;
1640 if ($result = $db->sql_query($sql))
1642 if ($db->sql_numrows($result))
1644 $data = $db->sql_fetchrowset($result);
1648 return $data;
1651 function tool_admin_domains_get_nel($application)
1653 global $db;
1655 $domain_data = null;
1657 if ($db->sql_select_db('nel'))
1659 $sql = "SELECT * FROM domain WHERE domain_name='". $application ."'";
1660 if ($result = $db->sql_query($sql))
1662 if ($db->sql_numrows($result))
1664 $domain_data = $db->sql_fetchrow($result);
1668 $db->sql_reselect_db();
1671 return $domain_data;
1674 //function tool_admin_domains_update_nel($domain_id, $domain_name, $domain_version, $domain_status)
1675 function tool_admin_domains_update_nel($domain_id, $domain_name, $domain_status)
1677 global $db;
1679 if ($db->sql_select_db('nel'))
1681 //$sql = "UPDATE domain SET status='". $domain_status ."',patch_version=". $domain_version ." WHERE domain_id=". $domain_id ." AND domain_name='". $domain_name ."'";
1682 $sql = "UPDATE domain SET status='". $domain_status ."' WHERE domain_id=". $domain_id ." AND domain_name='". $domain_name ."'";
1683 $db->sql_query($sql);
1685 $db->sql_reselect_db();
1689 function tool_admin_restarts_get_list($order='ASC')
1691 global $db;
1693 $data = null;
1695 $sql = "SELECT * FROM ". NELDB_RESTART_GROUP_TABLE ." ORDER BY restart_group_order ". $order .", restart_group_name ". $order;
1696 if ($result = $db->sql_query($sql))
1698 if ($db->sql_numrows($result))
1700 $data = $db->sql_fetchrowset($result);
1704 return $data;
1707 function tool_admin_restarts_add($restart_name, $restart_list, $restart_order)
1709 global $db;
1711 $restart_name = trim($restart_name);
1712 if ($restart_name == '') return "/!\ Error: restart group name is empty!";
1714 $restart_list = trim($restart_list);
1715 if ($restart_list == '') return "/!\ Error: restart group list is empty!";
1717 $restart_order = trim($restart_order);
1718 if (!is_numeric($restart_order)) return "/!\ Error: restart group order is not numeric!";
1720 $sql = "INSERT INTO ". NELDB_RESTART_GROUP_TABLE;
1721 $sql .= " (`restart_group_id`,`restart_group_name`,`restart_group_list`,`restart_group_order`) ";
1722 $sql .= " VALUES ";
1723 $sql .= " (0,'". $restart_name ."','". $restart_list ."','". $restart_order ."') ";
1724 $db->sql_query($sql);
1726 return "";
1729 function tool_admin_restarts_get_id($restart_id)
1731 global $db;
1733 $data = null;
1735 $sql = "SELECT * FROM ". NELDB_RESTART_GROUP_TABLE ." WHERE restart_group_id=". $restart_id;
1736 if ($result = $db->sql_query($sql))
1738 if ($db->sql_numrows($result))
1740 $data = $db->sql_fetchrow($result);
1744 return $data;
1747 function tool_admin_restarts_del($restart_id)
1749 global $db;
1751 $sql = "DELETE FROM ". NELDB_RESTART_GROUP_TABLE ." WHERE restart_group_id=". $restart_id;
1752 $db->sql_query($sql);
1755 function tool_admin_restarts_update($restart_id, $restart_name, $restart_list, $restart_order)
1757 global $db;
1759 $restart_name = trim($restart_name);
1760 if ($restart_name == '') return "/!\ Error: restart group name is empty!";
1762 $restart_list = trim($restart_list);
1763 if ($restart_list == '') return "/!\ Error: restart group list is empty!";
1765 $restart_order = trim($restart_order);
1766 if (!is_numeric($restart_order)) return "/!\ Error: restart group order is not numeric!";
1768 $sql = "UPDATE ". NELDB_RESTART_GROUP_TABLE ." SET restart_group_name='". $restart_name ."',restart_group_list='". $restart_list ."',restart_group_order='". $restart_order ."' WHERE restart_group_id=". $restart_id;
1769 $db->sql_query($sql);
1771 return "";
1774 function tool_admin_restart_messages_add($message_name, $message_value, $message_lang)
1776 global $db;
1778 $message_name = trim($message_name);
1779 if ($message_name == '') return "/!\ Error: restart message name is empty!";
1781 $message_value = trim($message_value);
1782 if ($message_value == '') return "/!\ Error: restart message value is empty!";
1784 $sql = "INSERT INTO ". NELDB_RESTART_MESSAGE_TABLE;
1785 $sql .= " (`restart_message_id`,`restart_message_name`,`restart_message_value`,`restart_message_lang`) ";
1786 $sql .= " VALUES ";
1787 $sql .= " (0,'". $message_name ."','". $message_value ."','". $message_lang ."') ";
1788 $db->sql_query($sql);
1790 return "";
1793 function tool_admin_restart_messages_get_list()
1795 global $db;
1797 $data = null;
1799 $sql = "SELECT * FROM ". NELDB_RESTART_MESSAGE_TABLE ." ORDER BY restart_message_name ASC, restart_message_lang ASC";
1800 if ($result = $db->sql_query($sql))
1802 if ($db->sql_numrows($result))
1804 $data = $db->sql_fetchrowset($result);
1808 return $data;
1811 function tool_admin_restart_messages_get_id($message_id)
1813 global $db;
1815 $data = null;
1817 $sql = "SELECT * FROM ". NELDB_RESTART_MESSAGE_TABLE ." WHERE restart_message_id=". $message_id;
1818 if ($result = $db->sql_query($sql))
1820 if ($db->sql_numrows($result))
1822 $data = $db->sql_fetchrow($result);
1826 return $data;
1829 function tool_admin_restart_messages_get_list_from_name($message_name,$lang=null)
1831 global $db;
1833 $data = null;
1835 $sql_ext = '';
1836 if ($lang !== null)
1838 $sql_ext = " AND restart_message_lang='". $lang ."'";
1841 $sql = "SELECT * FROM ". NELDB_RESTART_MESSAGE_TABLE ." WHERE restart_message_name='". $message_name ."' ". $sql_ext ." ORDER BY restart_message_lang ASC";
1842 if ($result = $db->sql_query($sql))
1844 if ($db->sql_numrows($result))
1846 $data = $db->sql_fetchrowset($result);
1850 return $data;
1853 function tool_admin_restart_messages_del($message_id)
1855 global $db;
1857 $sql = "DELETE FROM ". NELDB_RESTART_MESSAGE_TABLE ." WHERE restart_message_id=". $message_id;
1858 $db->sql_query($sql);
1861 function tool_admin_restart_messages_update($message_id, $message_name, $message_value, $message_lang)
1863 global $db;
1865 $message_name = trim($message_name);
1866 if ($message_name == '') return "/!\ Error: restart message name is empty!";
1868 $message_value = trim($message_value);
1869 if ($message_value == '') return "/!\ Error: restart message value is empty!";
1871 $sql = "UPDATE ". NELDB_RESTART_MESSAGE_TABLE ." SET restart_message_name='". $message_name ."',restart_message_value='". $message_value ."',restart_message_lang='". $message_lang ."' WHERE restart_message_id=". $message_id;
1872 $db->sql_query($sql);
1874 return "";