1 | <?php |
---|
2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | global $template, $page; |
---|
5 | |
---|
6 | $ecard = get_plugin_data($plugin_id); |
---|
7 | |
---|
8 | $start = (isset($_GET['start']) ? $_GET['start'] : 0); |
---|
9 | // Verify if the previous action is delete the last ecard on a page, go to first page |
---|
10 | if ($start != 0 and $ecard->get_nb_ecard() == $ecard->my_config['nb_ecard_page']) |
---|
11 | $start = 0; |
---|
12 | |
---|
13 | if (isset($_GET['action'])) { |
---|
14 | $action = $_GET['action']; |
---|
15 | // delete one ecard |
---|
16 | if ($action == "delete") { |
---|
17 | $ecard_id = $_GET['id']; |
---|
18 | $ecard->delete_ecard($ecard_id, isset($_GET['force'])); |
---|
19 | redirect(ECARD_ADMIN . '-consult&start='.$start); |
---|
20 | } elseif ($action == "delall") { // delete all unvalid |
---|
21 | $ecard->delete_allinvalid_ecard(); |
---|
22 | redirect(ECARD_ADMIN . '-consult'); |
---|
23 | } |
---|
24 | } |
---|
25 | |
---|
26 | //Create the navigation bar (for more than 1 page) |
---|
27 | $consult_url = ECARD_ADMIN.'-consult'; |
---|
28 | $ecard_navbar = array(); |
---|
29 | $ecard_navbar = create_navigation_bar($consult_url, $ecard->get_nb_ecard(), $start, $ecard->my_config['nb_ecard_page']); |
---|
30 | |
---|
31 | $query = 'SELECT * FROM '.ECARD_TABLE.' ORDER BY date DESC LIMIT '.$start.','.$ecard->my_config['nb_ecard_page'].';'; |
---|
32 | $result = pwg_query($query); |
---|
33 | |
---|
34 | while($file = mysql_fetch_assoc($result)) { |
---|
35 | $ecard_url = embellish_url(get_absolute_root_url() . './index.php?/ecard/'.$file['numero']); |
---|
36 | |
---|
37 | // Check if the ecard is valid |
---|
38 | if ($ecard->is_valid($file['numero'])) |
---|
39 | $actif = true; |
---|
40 | else |
---|
41 | $actif = false; |
---|
42 | |
---|
43 | $template->append('ecard_file',array( |
---|
44 | 'ID' => $file['numero'], |
---|
45 | 'SUJET' => $file['sujet'], |
---|
46 | 'LINK' => $ecard_url, |
---|
47 | 'FROM' => $file['nomexp'], |
---|
48 | 'FROMMAIL' => $file['adrexp'], |
---|
49 | 'TO' => $file['nomdest'], |
---|
50 | 'TOMAIL' => $file['adrdest'], |
---|
51 | 'DATE' => $file['date'], |
---|
52 | 'VALID' => $actif, |
---|
53 | 'ECARD_DELETE' => $consult_url.'&action=delete&id='.$file['numero'].'&start='.$start, |
---|
54 | 'ECARD_DELETE_ADM' => $consult_url.'&action=delete&id='.$file['numero'].'&force&start='.$start, |
---|
55 | )); |
---|
56 | } |
---|
57 | |
---|
58 | // Get the number of ecard (total & valid & invalid) |
---|
59 | $template->assign('NBECARDVALID', $ecard->get_nb_valid_ecard()); |
---|
60 | $template->assign('NBECARD', $ecard->get_nb_ecard()); |
---|
61 | |
---|
62 | $template->assign('ecard_del_all', $consult_url.'&action=delall' ); |
---|
63 | $template->assign('navbar', $ecard_navbar ); |
---|
64 | |
---|
65 | $template->set_filename('plugin_admin_consult', dirname(__FILE__) . '/template/admin_consult.tpl'); |
---|
66 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_consult'); |
---|
67 | ?> |
---|