1 | <?php |
---|
2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | global $template, $conf, $user; |
---|
4 | include_once(PHPWG_ROOT_PATH .'admin/include/tabsheet.class.php'); |
---|
5 | load_language('plugin.lang', IDS_PATH); |
---|
6 | $my_base_url = get_admin_plugin_menu_link(__FILE__); |
---|
7 | |
---|
8 | // +-----------------------------------------------------------------------+ |
---|
9 | // | Check Access and exit when user status is not ok | |
---|
10 | // +-----------------------------------------------------------------------+ |
---|
11 | check_status(ACCESS_ADMINISTRATOR); |
---|
12 | |
---|
13 | //-------------------------------------------------------- sections definitions |
---|
14 | |
---|
15 | // Gestion des onglets |
---|
16 | if (!isset($_GET['tab'])) |
---|
17 | $page['tab'] = 'IDS'; |
---|
18 | else |
---|
19 | $page['tab'] = $_GET['tab']; |
---|
20 | |
---|
21 | $tabsheet = new tabsheet(); |
---|
22 | $tabsheet->add('IDS', |
---|
23 | l10n('ids_tab1'), |
---|
24 | $my_base_url.'&tab=IDS'); |
---|
25 | $tabsheet->select($page['tab']); |
---|
26 | $tabsheet->assign(); |
---|
27 | |
---|
28 | switch ($page['tab']) |
---|
29 | { |
---|
30 | // tab switch |
---|
31 | case 'IDS': |
---|
32 | |
---|
33 | $groups = array(); |
---|
34 | $query = ' |
---|
35 | select id,name |
---|
36 | FROM ' . IMAGES_TABLE . ' |
---|
37 | ORDER BY id ASC;'; |
---|
38 | $result = pwg_query($query); |
---|
39 | |
---|
40 | while ($row = mysql_fetch_array($result)) |
---|
41 | { |
---|
42 | $groups[$row['id']] = $row['id'].' : '.$row['name']; |
---|
43 | } |
---|
44 | |
---|
45 | $selected = 0; |
---|
46 | $options[] = l10n('ids_select'); |
---|
47 | $options['a'] = '----------------------'; |
---|
48 | |
---|
49 | foreach($groups as $listid => $listid2) |
---|
50 | { |
---|
51 | $options[$listid] = $listid2; |
---|
52 | } |
---|
53 | $template->assign( |
---|
54 | 'gestion', |
---|
55 | array( |
---|
56 | 'OPTIONS' => $options, |
---|
57 | 'SELECTED' => $selected |
---|
58 | )); |
---|
59 | |
---|
60 | //action |
---|
61 | if (isset($_POST['IDS'])and is_numeric($_POST['IDS1']) and (!$_POST['IDS1'])==0 and is_numeric($_POST['IDS2']) and (!$_POST['IDS2'])==0) |
---|
62 | { |
---|
63 | |
---|
64 | $query = ' |
---|
65 | select id |
---|
66 | FROM ' . IMAGES_TABLE . ' |
---|
67 | ORDER BY id DESC;'; |
---|
68 | $result = pwg_query($query); |
---|
69 | $row = mysql_fetch_array($result); |
---|
70 | $tempoids=$row['id']+1000; |
---|
71 | |
---|
72 | $query = ' |
---|
73 | UPDATE ' . IMAGES_TABLE . ' |
---|
74 | SET id= \''.$tempoids.'\' |
---|
75 | WHERE id = \''.$_POST['IDS1'].'\' |
---|
76 | ;'; |
---|
77 | $result = pwg_query($query); |
---|
78 | |
---|
79 | $query = ' |
---|
80 | UPDATE ' . IMAGES_TABLE . ' |
---|
81 | SET id= \''.$_POST['IDS1'].'\' |
---|
82 | WHERE id = \''.$_POST['IDS2'].'\' |
---|
83 | ;'; |
---|
84 | $result = pwg_query($query); |
---|
85 | |
---|
86 | $query = ' |
---|
87 | UPDATE ' . IMAGES_TABLE . ' |
---|
88 | SET id= \''.$_POST['IDS2'].'\' |
---|
89 | WHERE id = \''.$tempoids.'\' |
---|
90 | ;'; |
---|
91 | $result = pwg_query($query); |
---|
92 | |
---|
93 | $groups = array(); |
---|
94 | $query = ' |
---|
95 | select id,name |
---|
96 | FROM ' . IMAGES_TABLE . ' |
---|
97 | ORDER BY id ASC;'; |
---|
98 | $result = pwg_query($query); |
---|
99 | |
---|
100 | while ($row = mysql_fetch_array($result)) |
---|
101 | { |
---|
102 | $groups[$row['id']] = $row['id'].' : '.$row['name']; |
---|
103 | } |
---|
104 | |
---|
105 | $selected = 0; |
---|
106 | $options[] = l10n('ids_select'); |
---|
107 | $options['a'] = '----------------------'; |
---|
108 | |
---|
109 | foreach($groups as $listid => $listid2) |
---|
110 | { |
---|
111 | $options[$listid] = $listid2; |
---|
112 | } |
---|
113 | $template->assign( |
---|
114 | 'gestion', |
---|
115 | array( |
---|
116 | 'OPTIONS' => $options, |
---|
117 | 'SELECTED' => $selected |
---|
118 | )); |
---|
119 | |
---|
120 | array_push( $page['infos'], l10n('ids_ok') ); |
---|
121 | } |
---|
122 | |
---|
123 | break; |
---|
124 | |
---|
125 | } |
---|
126 | |
---|
127 | $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl')); |
---|
128 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
129 | ?> |
---|