source: extensions/ID_swicht/admin/admin.php @ 10591

Last change on this file since 10591 was 10591, checked in by ddtddt, 13 years ago

[extensions] - ID_swicht - First release

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 2.9 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3global $template, $conf, $user;
4include_once(PHPWG_ROOT_PATH .'admin/include/tabsheet.class.php');
5load_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// +-----------------------------------------------------------------------+
11check_status(ACCESS_ADMINISTRATOR);
12
13//-------------------------------------------------------- sections definitions
14
15// Gestion des onglets
16if (!isset($_GET['tab']))
17    $page['tab'] = 'IDS';
18else
19    $page['tab'] = $_GET['tab'];
20
21$tabsheet = new tabsheet();
22$tabsheet->add('IDS',
23               l10n('ids_tab1'),
24               $my_base_url.'&amp;tab=IDS');
25$tabsheet->select($page['tab']);
26$tabsheet->assign();
27
28switch ($page['tab'])
29{
30// tab switch
31  case 'IDS':
32
33$groups = array();
34$query = '
35select id,name
36  FROM ' . IMAGES_TABLE . '
37  ORDER BY id ASC;';
38$result = pwg_query($query);
39
40while ($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       
49foreach($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
61if (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 = '
65select 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 = '
73UPDATE ' . IMAGES_TABLE . '
74  SET id= \''.$tempoids.'\'
75  WHERE id = \''.$_POST['IDS1'].'\'
76    ;';
77$result = pwg_query($query);
78
79        $query = '
80UPDATE ' . IMAGES_TABLE . '
81  SET id= \''.$_POST['IDS1'].'\'
82  WHERE id = \''.$_POST['IDS2'].'\'
83    ;';
84$result = pwg_query($query);
85
86        $query = '
87UPDATE ' . IMAGES_TABLE . '
88  SET id= \''.$_POST['IDS2'].'\'
89  WHERE id = \''.$tempoids.'\'
90    ;';
91$result = pwg_query($query);
92
93$groups = array();
94$query = '
95select id,name
96  FROM ' . IMAGES_TABLE . '
97  ORDER BY id ASC;';
98$result = pwg_query($query);
99
100while ($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       
109foreach($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?>
Note: See TracBrowser for help on using the repository browser.