1 | <?php |
---|
2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | global $template, $page; |
---|
5 | |
---|
6 | $piwecard = get_plugin_data($plugin_id); |
---|
7 | |
---|
8 | if (isset($_POST['submit'])) { |
---|
9 | $piwecard->my_config['nb_ecard_page'] = $_POST['ecard_nb_ecard_page']; |
---|
10 | $piwecard->save_config(); |
---|
11 | } |
---|
12 | |
---|
13 | $start = (isset($_GET['start']) ? $_GET['start'] : 0); |
---|
14 | // Verify if the previous action is delete the last ecard on a page, go to first page |
---|
15 | if ($start != 0 and $piwecard->get_nb_ecard() == $piwecard->my_config['nb_ecard_page']) |
---|
16 | $start = 0; |
---|
17 | |
---|
18 | if (isset($_GET['action'])) { |
---|
19 | switch ($_GET['action']) { |
---|
20 | case "delete" : |
---|
21 | $ecard_id = $_GET['id']; |
---|
22 | $piwecard->delete_ecard($ecard_id); |
---|
23 | redirect(ECARD_ADMIN . '-consult&start='.$start); |
---|
24 | break; |
---|
25 | case "delall" : |
---|
26 | $piwecard->delete_allinvalid_ecard(); |
---|
27 | redirect(ECARD_ADMIN . '-consult'); |
---|
28 | break; |
---|
29 | default : |
---|
30 | break; |
---|
31 | } |
---|
32 | } |
---|
33 | |
---|
34 | //Create the navigation bar (for more than 1 page) |
---|
35 | $consult_url = ECARD_ADMIN.'-consult'; |
---|
36 | $ecard_navbar = array(); |
---|
37 | $ecard_navbar = create_navigation_bar($consult_url, $piwecard->get_nb_ecard(), $start, $piwecard->my_config['nb_ecard_page']); |
---|
38 | |
---|
39 | $query = 'SELECT * FROM '.ECARD_TABLE.' ORDER BY date_creation DESC LIMIT '.$start.','.$piwecard->my_config['nb_ecard_page'].';'; |
---|
40 | $result = pwg_query($query); |
---|
41 | |
---|
42 | while($file = pwg_db_fetch_assoc($result)) { |
---|
43 | $ecard_url = embellish_url(get_absolute_root_url() . './index.php?/ecard/'.$file['id']); |
---|
44 | |
---|
45 | // Check if the ecard is valid |
---|
46 | $valid = $piwecard->is_valid($file['id']); |
---|
47 | |
---|
48 | $template->append('ecard_file',array( |
---|
49 | 'id' => $file['id'], |
---|
50 | 'subject' => $file['subject'], |
---|
51 | 'url' => $ecard_url, |
---|
52 | 'sender_name' => $file['sender_name'], |
---|
53 | 'sender_email' => $file['sender_email'], |
---|
54 | 'recipient_name' => $file['recipient_name'], |
---|
55 | 'recipient_email' => $file['recipient_email'], |
---|
56 | 'date_creation' => strftime('%d/%m/%y %H:%M', strtotime($file['date_creation'])), |
---|
57 | 'date_validity' => (isset($file['date_validity'])) ? strftime('%d/%m/%y %H:%M', strtotime($file['date_validity'])) : l10n('ecard_nolimit'), |
---|
58 | 'valid' => $valid, |
---|
59 | 'delete' => $consult_url.'&action=delete&id='.$file['id'].'&start='.$start, |
---|
60 | )); |
---|
61 | } |
---|
62 | |
---|
63 | $template->assign('nb_ecard_valid', $piwecard->get_nb_valid_ecard()); |
---|
64 | $template->assign('nb_ecard', $piwecard->get_nb_ecard()); |
---|
65 | $template->assign('ecard_nb_ecard_page', $piwecard->my_config['nb_ecard_page']); |
---|
66 | $template->assign('ecard_del_all', $consult_url.'&action=delall' ); |
---|
67 | $template->assign('navbar', $ecard_navbar ); |
---|
68 | |
---|
69 | $template->set_filename('plugin_admin_consult', dirname(__FILE__) . '/template/admin_consult.tpl'); |
---|
70 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_consult'); |
---|
71 | ?> |
---|