source: extensions/delete_rate/admin/admin.php @ 7894

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

[extensions] - delete_rate - News plugin

  • Property svn:eol-style set to LF
  • Property svn:keywords set to Author Date Id Revision
File size: 2.7 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', RATE_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
16
17// Gestion des onglets
18if (!isset($_GET['tab']))
19    $page['tab'] = 'rateall';
20else
21    $page['tab'] = $_GET['tab'];
22
23$tabsheet = new tabsheet();
24$tabsheet->add('rateall',
25               l10n('rate_onglet_all'),
26               $my_base_url.'&amp;tab=rateall');
27$tabsheet->add('ratephoto',
28               l10n('rate_onglet_photo'),
29               $my_base_url.'&amp;tab=ratephoto');
30
31$tabsheet->select($page['tab']);
32$tabsheet->assign();
33
34// Onglet gestion par photo
35switch ($page['tab'])
36{
37 case 'rateall':
38
39  $template->assign(
40    'gestion',
41    array(
42
43      ));
44
45//purge photo
46if (isset($_POST['submitchoixall']) and !is_adviser())
47        {
48        $query = '
49UPDATE ' . IMAGES_TABLE . '
50  SET average_rate= \'NULL\'
51    ;';
52$result = pwg_query($query);
53
54        $query = '
55TRUNCATE ' . RATE_TABLE . '
56    ;';
57$result = pwg_query($query);
58
59        array_push( $page['infos'], l10n('rate_totalok') );
60        }
61         
62    break;
63       
64  case 'ratephoto':
65
66//charge la liste des photos
67$groups = array();
68$query = '
69SELECT id,name
70  FROM ' . IMAGES_TABLE . '
71  ORDER BY id ASC;';
72$result = pwg_query($query);
73
74while ($row = mysql_fetch_array($result))
75        {
76  $groups[$row['id']] = $row['id'].' : '.$row['name'];
77        }
78       
79        $selected = 0;
80        $options[] = l10n('rate_select_photo');
81        $options['a'] = '----------------------';
82       
83foreach($groups as $listid => $listid2)
84        {
85    $options[$listid] = $listid2;
86        }
87  $template->assign(
88    'gestionA',
89    array(
90          'OPTIONS' => $options,
91      'SELECTED' => $selected
92      ));
93
94//purge photo
95if (isset($_POST['submitchoixphoto']) and is_numeric($_POST['delratephoto'])and (!$_POST['delratephoto'])==0 and !is_adviser())
96        {
97        $lire=$_POST['delratephoto'];
98        $query = '
99UPDATE ' . IMAGES_TABLE . '
100  SET average_rate = \'NULL\'
101  WHERE id = \''.$lire.'\'
102    ;';
103$result = pwg_query($query);
104
105        $query = '
106  DELETE FROM ' . RATE_TABLE . '
107  WHERE element_id = \''.$lire.'\'
108    ;';
109$result = pwg_query($query);
110       
111        array_push( $page['infos'], l10n('rate_photook') );
112        }
113         
114    break;
115       
116} 
117
118$template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/admin.tpl')); 
119$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
120?>
Note: See TracBrowser for help on using the repository browser.