[8771] | 1 | <?php |
---|
| 2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | |
---|
| 4 | global $template, $page; |
---|
| 5 | |
---|
| 6 | |
---|
| 7 | $me = get_plugin_data($plugin_id); |
---|
| 8 | |
---|
| 9 | $start = (isset($_GET['start']) ? $_GET['start'] : 0); |
---|
| 10 | |
---|
| 11 | // Verify if the previous action is delete the last ecard on a page, go to first page |
---|
| 12 | if ($start != 0 |
---|
| 13 | and $me->get_nb_ecard() == $me->my_config['nb_ecard_page'] |
---|
| 14 | ) |
---|
| 15 | $start = 0 ; |
---|
| 16 | |
---|
| 17 | if (isset($_GET['action'])) |
---|
| 18 | { |
---|
| 19 | $action = $_GET['action']; |
---|
| 20 | // delete one unvalid |
---|
| 21 | if ($action == "delete") |
---|
| 22 | { |
---|
| 23 | $ecard_id = $_GET['id']; |
---|
| 24 | $me->delete_ecard($ecard_id, isset($_GET['force'])); |
---|
| 25 | redirect( PHPWG_ROOT_PATH . 'admin.php?page=plugin&section=' . ECARD_DIR . '%2Fadmin%2Fadmin.php&tab=consult&start='.$start); |
---|
| 26 | |
---|
| 27 | } |
---|
| 28 | elseif ($action == "delall") // delete all unvalid |
---|
| 29 | { |
---|
| 30 | $me->delete_allinvalid_ecard(); |
---|
| 31 | redirect( PHPWG_ROOT_PATH . 'admin.php?page=plugin&section=' . ECARD_DIR . '%2Fadmin%2Fadmin.php&tab=consult'); |
---|
| 32 | } |
---|
| 33 | } |
---|
| 34 | |
---|
| 35 | |
---|
| 36 | |
---|
| 37 | // Create the navigation bar (for more than 1 page) |
---|
| 38 | $url = PHPWG_ROOT_PATH . 'admin.php?page=plugin&section=' . ECARD_DIR . '%2Fadmin%2Fadmin.php&tab=consult'; |
---|
| 39 | //PHPWG_ROOT_PATH . 'admin.php?page=plugin&section=' . ECARD_DIR . '%2Fadmin%2Fconsult.php'; |
---|
| 40 | $ecard_navbar = array(); |
---|
| 41 | $ecard_navbar = create_navigation_bar( |
---|
| 42 | $url, $me->get_nb_ecard(), $start, $me->my_config['nb_ecard_page']); |
---|
| 43 | |
---|
| 44 | $query = 'SELECT * FROM '.ECARD_TABLE |
---|
| 45 | . ' ORDER BY date DESC' |
---|
| 46 | . ' LIMIT '.$start.','.$me->my_config['nb_ecard_page'] |
---|
| 47 | .';'; |
---|
| 48 | $result = pwg_query($query); |
---|
| 49 | //$tableau = mysql_fetch_assoc($result); |
---|
| 50 | |
---|
| 51 | |
---|
| 52 | while($file = mysql_fetch_assoc($result)) |
---|
| 53 | { |
---|
| 54 | // echo "numero=".$file['numero']; |
---|
| 55 | $chemin = embellish_url(get_absolute_root_url() . './index.php?/ecard/'.$file['numero']); |
---|
| 56 | |
---|
| 57 | if ($me->debug) |
---|
| 58 | { |
---|
| 59 | echo "date = ".date("Y-m-d H:m:s"); |
---|
| 60 | echo " / date file = ".$file['date']; |
---|
| 61 | echo " / config= ".$me->my_config['activ']; |
---|
| 62 | echo " / Nbjours = ".$me->NbJours($file['date'], date("Y-m-d H:m:s")); |
---|
| 63 | } |
---|
| 64 | |
---|
| 65 | // Check if the ecard is valid |
---|
| 66 | |
---|
| 67 | if ($me->is_valid($file['numero'])) |
---|
| 68 | $actif = true; |
---|
| 69 | else |
---|
| 70 | $actif = false; |
---|
| 71 | |
---|
| 72 | |
---|
| 73 | /* |
---|
| 74 | if ($me->my_config['activ'] == 0) // unlimited |
---|
| 75 | $actif = true; |
---|
| 76 | elseif ($me->NbJours($file['date'], date("Y-m-d H:m:s")) > $me->my_config['activ']) // during the validate time |
---|
| 77 | $actif = false; |
---|
| 78 | else |
---|
| 79 | $actif = true; |
---|
| 80 | */ |
---|
| 81 | |
---|
| 82 | |
---|
| 83 | $template->append('FILE',array( 'ID' => $file['numero'], |
---|
| 84 | 'SUJET' => $file['sujet'], |
---|
| 85 | 'LINK' => $chemin, |
---|
| 86 | 'FROM' => $file['nomexp'], |
---|
| 87 | 'FROMMAIL'=> $file['adrexp'], |
---|
| 88 | 'TO' => $file['nomdest'], |
---|
| 89 | 'TOMAIL' => $file['adrdest'], |
---|
| 90 | 'DATE' => $file['date'], |
---|
| 91 | 'VALID' => $actif, |
---|
| 92 | 'ECARD_DELETE' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&section=' . ECARD_DIR . '%2Fadmin%2Fconsult.php&action=delete&id='.$file['numero'].'&start='.$start, |
---|
| 93 | 'ECARD_DELETE_ADM' => PHPWG_ROOT_PATH . 'admin.php?page=plugin&section=' . ECARD_DIR . '%2Fadmin%2Fconsult.php&action=delete&id='.$file['numero'].'&force&start='.$start, |
---|
| 94 | |
---|
| 95 | |
---|
| 96 | |
---|
| 97 | )); |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | // Get the number of ecard (total & valid & invalid) |
---|
| 101 | $template->assign( 'NBECARDVALID', $me->get_nb_valid_ecard()); |
---|
| 102 | $template->assign( 'NBECARD', $me->get_nb_ecard()); |
---|
| 103 | |
---|
| 104 | |
---|
| 105 | $template->assign( 'DELALL', PHPWG_ROOT_PATH . 'admin.php?page=plugin&section=' . ECARD_DIR . '%2Fadmin%2Fconsult.php&action=delall&' ); |
---|
| 106 | $template->assign( 'navbar', $ecard_navbar ); |
---|
| 107 | |
---|
| 108 | $template->set_filename('plugin_admin_content', dirname(__FILE__) . '/template/consult.tpl'); |
---|
| 109 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 110 | |
---|
| 111 | |
---|
| 112 | |
---|
| 113 | ?> |
---|