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['nb_ecard_page_submit'])) { |
---|
9 | if (intval($_POST['ecard_nb_ecard_page']) == 0) |
---|
10 | $piwecard->my_config['nb_ecard_page'] = 1; |
---|
11 | else |
---|
12 | $piwecard->my_config['nb_ecard_page'] = intval($_POST['ecard_nb_ecard_page']); |
---|
13 | $piwecard->set_config(); |
---|
14 | } |
---|
15 | |
---|
16 | if (isset($_POST['delete_selected_submit'])) { |
---|
17 | if (isset($_POST['ecard_to_delete_sure']) && $_POST['ecard_to_delete_sure'] == '1') { |
---|
18 | if (isset($_POST['ecard_to_delete'])) { |
---|
19 | foreach ($_POST['ecard_to_delete'] as $ecard_id) { |
---|
20 | $piwecard->delete_ecard($ecard_id); |
---|
21 | } |
---|
22 | array_push($page['infos'], l10n('piwecard_deleted')); |
---|
23 | } |
---|
24 | if (isset($_POST['ecard_delete_invalid']) && $_POST['ecard_delete_invalid'] == '1') { |
---|
25 | $piwecard->delete_allinvalid_ecard(); |
---|
26 | array_push($page['infos'], l10n('piwecard_invalid_deleted')); |
---|
27 | } |
---|
28 | } else { |
---|
29 | array_push($page['errors'], l10n('You need to confirm deletion')); |
---|
30 | } |
---|
31 | } |
---|
32 | |
---|
33 | $start = (isset($_GET['start']) ? $_GET['start'] : 0); |
---|
34 | if ($start != 0 and $piwecard->get_nb_ecard() == $piwecard->my_config['nb_ecard_page']) |
---|
35 | $start = 0; |
---|
36 | |
---|
37 | //Create the navigation bar (for more than 1 page) |
---|
38 | $management_url = PIWECARD_ADMIN.'-management'; |
---|
39 | $ecard_navbar = array(); |
---|
40 | $ecard_navbar = create_navigation_bar($management_url, $piwecard->get_nb_ecard(), $start, $piwecard->my_config['nb_ecard_page']); |
---|
41 | |
---|
42 | $query = 'SELECT * FROM '.PIWECARD_TABLE.' ORDER BY date_creation DESC LIMIT '.$start.','.$piwecard->my_config['nb_ecard_page'].';'; |
---|
43 | $result = pwg_query($query); |
---|
44 | |
---|
45 | while($file = pwg_db_fetch_assoc($result)) { |
---|
46 | $ecard_url = embellish_url(get_absolute_root_url() . './index.php?/ecard/'.$file['id']); |
---|
47 | |
---|
48 | // Check if the ecard is valid |
---|
49 | $valid = $piwecard->is_valid($file['id']); |
---|
50 | |
---|
51 | $template->append('ecard_file',array( |
---|
52 | 'id' => $file['id'], |
---|
53 | 'title' => $file['title'], |
---|
54 | 'url' => $ecard_url, |
---|
55 | 'sender_name' => $file['sender_name'], |
---|
56 | 'sender_email' => $file['sender_email'], |
---|
57 | 'recipient_name' => $file['recipient_name'], |
---|
58 | 'recipient_email' => $file['recipient_email'], |
---|
59 | 'date_creation' => strftime('%d/%m/%y %H:%M', strtotime($file['date_creation'])), |
---|
60 | 'date_validity' => (isset($file['date_validity'])) ? strftime('%d/%m/%y %H:%M', strtotime($file['date_validity'])) : l10n('piwecard_nolimit'), |
---|
61 | 'valid' => $valid, |
---|
62 | )); |
---|
63 | } |
---|
64 | |
---|
65 | $nb_ecard_valid_total = str_replace(array('%nb_valid%', '%nb_total%'), array($piwecard->get_nb_valid_ecard(), $piwecard->get_nb_ecard()), l10n('piwecard_nb_ecard_valid_total')); |
---|
66 | |
---|
67 | $template->assign('nb_ecard_valid_total', $nb_ecard_valid_total); |
---|
68 | $template->assign('ecard_nb_ecard_page', $piwecard->my_config['nb_ecard_page']); |
---|
69 | $template->assign('navbar', $ecard_navbar); |
---|
70 | |
---|
71 | $template->set_filename('plugin_admin_management', dirname(__FILE__) . '/template/admin_management.tpl'); |
---|
72 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_management'); |
---|
73 | ?> |
---|