source: extensions/Piwecard/admin/admin_consult.php @ 19956

Last change on this file since 19956 was 19956, checked in by julien1311, 11 years ago

[piwecard] various improvements

  • Property svn:eol-style set to native
File size: 2.5 KB
Line 
1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4global $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
10if ($start != 0 and $ecard->get_nb_ecard() == $ecard->my_config['nb_ecard_page'])
11        $start = 0;
12
13if (isset($_GET['action'])) {
14        switch ($_GET['action']) {
15                case "delete" :
16                        $ecard_id = $_GET['id'];
17                        $ecard->delete_ecard($ecard_id);
18                        redirect(ECARD_ADMIN . '-consult&amp;start='.$start);
19                        break;
20                case "delall" :
21                        $ecard->delete_allinvalid_ecard();
22                        redirect(ECARD_ADMIN . '-consult');
23                        break;
24                default :
25                        break;
26        }
27}
28
29
30//Create the navigation bar (for more than 1 page)
31$consult_url = ECARD_ADMIN.'-consult';
32$ecard_navbar = array();
33$ecard_navbar = create_navigation_bar($consult_url, $ecard->get_nb_ecard(), $start, $ecard->my_config['nb_ecard_page']);
34
35$query = 'SELECT * FROM '.ECARD_TABLE.' ORDER BY date_creation DESC LIMIT '.$start.','.$ecard->my_config['nb_ecard_page'].';';
36$result = pwg_query($query);
37
38while($file = mysql_fetch_assoc($result)) {
39        $ecard_url = embellish_url(get_absolute_root_url() . './index.php?/ecard/'.$file['id']);
40
41        // Check if the ecard is valid
42        $valid = $ecard->is_valid($file['id']);
43
44        $template->append('ecard_file',array(
45                                                                        'id'                            => $file['id'],
46                                                                        'subject'                       => $file['subject'],
47                                                                        'url'                           => $ecard_url,
48                                                                        'sender_name'           => $file['sender_name'],
49                                                                        'sender_email'          => $file['sender_email'],
50                                                                        'recipient_name'        => $file['recipient_name'],
51                                                                        'recipient_email'       => $file['recipient_email'],
52                                                                        'date_creation'         => strftime('%d/%m/%y %H:%M', strtotime($file['date_creation'])),
53                                                                        'date_validity'         => (isset($file['date_validity'])) ? strftime('%d/%m/%y %H:%M', strtotime($file['date_validity'])) : l10n('ecard_nolimit'),
54                                                                        'valid'                         => $valid,
55                                                                        'delete'                        => $consult_url.'&amp;action=delete&amp;id='.$file['id'].'&amp;start='.$start,
56        ));
57}
58
59// Get the number of ecard (total & valid & invalid)
60$template->assign('nb_ecard_valid', $ecard->get_nb_valid_ecard());
61$template->assign('nb_ecard', $ecard->get_nb_ecard());
62
63$template->assign('ecard_del_all', $consult_url.'&amp;action=delall' );
64$template->assign('navbar', $ecard_navbar );
65
66$template->set_filename('plugin_admin_consult', dirname(__FILE__) . '/template/admin_consult.tpl');
67$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_consult');
68?>
Note: See TracBrowser for help on using the repository browser.