source: extensions/ID_switch/admin/admin.php @ 25973

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

[extensions] - ID_switch - update

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 3.6 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, hit, has_high, average_rate, path
66  FROM ' . IMAGES_TABLE . '
67  WHERE id = \''.$_POST['IDS1'].'\'
68  ;';
69$result = pwg_query($query);
70$row = mysql_fetch_array($result);     
71$id1=$row['id'];
72$hit1=$row['hit'];
73$has_high1=$row['has_high'];
74$average_rate1=$row['average_rate'];
75
76$query = '
77select id, hit, has_high, average_rate, path
78  FROM ' . IMAGES_TABLE . '
79  WHERE id = \''.$_POST['IDS2'].'\'
80  ;';
81$result = pwg_query($query);
82$row = mysql_fetch_array($result);     
83$id2=$row['id'];
84$hit2=$row['hit'];
85$has_high2=$row['has_high'];
86$average_rate2=$row['average_rate'];
87
88$query = '
89select id
90  FROM ' . IMAGES_TABLE . '
91  ORDER BY id DESC;';
92$result = pwg_query($query);
93$row = mysql_fetch_array($result);     
94$tempoids=$row['id']+1000;
95
96        $query = '
97UPDATE ' . IMAGES_TABLE . '
98  SET id= \''.$tempoids.'\'
99  WHERE id = \''.$_POST['IDS1'].'\'
100    ;';
101$result = pwg_query($query);
102
103        $query = '
104UPDATE ' . IMAGES_TABLE . '
105  SET id= \''.$_POST['IDS1'].'\',
106                hit= \''.$hit1.'\',
107                average_rate= \''.$average_rate1.'\'
108  WHERE id = \''.$_POST['IDS2'].'\'
109    ;';
110$result = pwg_query($query);
111
112        $query = '
113UPDATE ' . IMAGES_TABLE . '
114  SET id= \''.$_POST['IDS2'].'\',
115                hit= \''.$hit2.'\',
116                average_rate= \''.$average_rate2.'\'
117  WHERE id = \''.$tempoids.'\'
118    ;';
119$result = pwg_query($query);
120
121$groups = array();
122$query = '
123select id,name
124  FROM ' . IMAGES_TABLE . '
125  ORDER BY id ASC;';
126$result = pwg_query($query);
127
128while ($row = mysql_fetch_array($result))
129        {
130  $groups[$row['id']] = $row['id'].' : '.$row['name'];
131        }
132       
133        $selected = 0;
134        $options[] = l10n('ids_select');
135        $options['a'] = '----------------------';
136       
137foreach($groups as $listid => $listid2)
138        {
139    $options[$listid] = $listid2;
140        }
141  $template->assign(
142    'gestion',
143    array(
144          'OPTIONS' => $options,
145      'SELECTED' => $selected
146      )); 
147
148  array_push( $page['infos'], l10n('ids_ok') );
149        } 
150 
151        break;
152       
153} 
154
155$template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl')); 
156$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
157?>
Note: See TracBrowser for help on using the repository browser.