[6768] | 1 | <?php |
---|
| 2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | |
---|
| 4 | // Les quatre zones de texte principales |
---|
| 5 | $textareas = array('presentation','rules','prices','final'); |
---|
| 6 | |
---|
| 7 | // +-----------------------------------------------------------------------+ |
---|
[9200] | 8 | // Ajout ou modification d'un concours |
---|
[6768] | 9 | // +-----------------------------------------------------------------------+ |
---|
[9200] | 10 | if (isset($_POST['new_submit'])) { |
---|
[6768] | 11 | // Modification d'un concours |
---|
[9200] | 12 | if (isset($_GET['contest_id'])) { |
---|
| 13 | pwg_query("UPDATE " . CR_TABLE_1 . " SET |
---|
[6768] | 14 | `name` = '" . $_POST['name'] ."', |
---|
| 15 | `status` = '" . $_POST['status'] ."', |
---|
| 16 | `visible` = '" . $_POST['visible'] ."', |
---|
| 17 | `date_begin` = '" . $_POST['date_begin'] ."', |
---|
| 18 | `date_end` = '" . $_POST['date_end'] ."', |
---|
| 19 | `logo` = '" . $_POST['logo'] ."', |
---|
| 20 | `banner` = '" . $_POST['banner'] ."', |
---|
| 21 | `summary` = '" . $_POST['summary'] ."', |
---|
| 22 | `presentation` = '" . $_POST['presentation'] ."', |
---|
| 23 | `rules` = '" . $_POST['rules'] ."', |
---|
| 24 | `prices` = '" . $_POST['prices'] ."', |
---|
[9200] | 25 | `final` = '" . $_POST['final'] ."' |
---|
| 26 | WHERE `id` = " . $_GET['contest_id'] .";"); |
---|
[6768] | 27 | |
---|
[9200] | 28 | // redirige vers la page du concours si on en viens |
---|
| 29 | if (isset($_GET['redirect']) AND $_GET['redirect'] == 'page') { |
---|
| 30 | redirect(CR_PUBLIC . $_GET['contest_id'] . '-' . str2url(trigger_event('render_CR_content', $_POST['name']))); |
---|
| 31 | } else { |
---|
| 32 | redirect(CR_ADMIN); |
---|
| 33 | } |
---|
[6768] | 34 | |
---|
| 35 | // Ajout d'un concours |
---|
[9200] | 36 | } else { |
---|
| 37 | pwg_query("INSERT INTO " . CR_TABLE_1 . " |
---|
[6768] | 38 | ( |
---|
| 39 | name, |
---|
| 40 | date_begin, |
---|
| 41 | date_end, |
---|
| 42 | status, |
---|
| 43 | visible, |
---|
| 44 | logo, |
---|
| 45 | banner, |
---|
| 46 | summary, |
---|
| 47 | presentation, |
---|
| 48 | rules, |
---|
| 49 | prices, |
---|
[9200] | 50 | final |
---|
[6768] | 51 | ) |
---|
| 52 | VALUES( |
---|
| 53 | '" . $_POST['name'] ."', |
---|
| 54 | '" . $_POST['date_begin'] ."', |
---|
| 55 | '" . $_POST['date_end'] ."', |
---|
| 56 | '" . $_POST['status'] ."', |
---|
| 57 | '" . $_POST['visible'] ."', |
---|
| 58 | '" . $_POST['logo'] ."', |
---|
| 59 | '" . $_POST['banner'] ."', |
---|
| 60 | '" . $_POST['summary'] ."', |
---|
| 61 | '" . $_POST['presentation'] ."', |
---|
| 62 | '" . $_POST['rules'] ."', |
---|
| 63 | '" . $_POST['prices'] ."', |
---|
[9200] | 64 | '" . $_POST['final'] ."' |
---|
| 65 | );"); |
---|
[6768] | 66 | redirect(CR_ADMIN); |
---|
| 67 | } |
---|
| 68 | } |
---|
| 69 | |
---|
| 70 | |
---|
| 71 | // +-----------------------------------------------------------------------+ |
---|
[9200] | 72 | // Définition des variables template |
---|
[6768] | 73 | // +-----------------------------------------------------------------------+ |
---|
| 74 | // Edition d'un concours |
---|
[9200] | 75 | if (isset($_GET['contest_id'])) { |
---|
[6768] | 76 | $query = "SELECT * FROM " . CR_TABLE_1 . " WHERE id = " . $_GET['contest_id'] . ";"; |
---|
| 77 | $contest = pwg_db_fetch_assoc(pwg_query($query)); |
---|
| 78 | |
---|
| 79 | $template->assign(array( |
---|
| 80 | 'ID' => $contest['id'], |
---|
| 81 | 'NAME' => $contest['name'], |
---|
| 82 | 'STATUS' => $contest['status'], |
---|
| 83 | 'VISIBLE' => $contest['visible'], |
---|
| 84 | 'DATE_BEGIN' => $contest['date_begin'], |
---|
| 85 | 'DATE_END' => $contest['date_end'], |
---|
| 86 | 'LOGO' => $contest['logo'], |
---|
| 87 | 'BANNER' => $contest['banner'], |
---|
| 88 | 'SUMMARY' => $contest['summary'], |
---|
| 89 | )); |
---|
| 90 | |
---|
[9200] | 91 | foreach ($textareas AS $key) { |
---|
[6768] | 92 | $template->assign(strtoupper($key), $contest[$key]); |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | // Ajout d'un concours |
---|
[9200] | 96 | } else { |
---|
[6768] | 97 | $template->assign(array( |
---|
| 98 | 'NAME' => null, |
---|
| 99 | 'STATUS' => 'pending', |
---|
| 100 | 'VISIBLE' => 1, |
---|
| 101 | 'DATE_BEGIN' => date('Y-m-d'), |
---|
| 102 | 'DATE_END' => date('Y-m-d', time()+2592000), |
---|
| 103 | 'LOGO' => null, |
---|
| 104 | 'BANNER' => null, |
---|
| 105 | 'SUMMARY' => null, |
---|
| 106 | )); |
---|
| 107 | |
---|
[9200] | 108 | foreach ($textareas AS $key) { |
---|
| 109 | $template->assign(strtoupper($key), null); |
---|
[6768] | 110 | } |
---|
| 111 | } |
---|
| 112 | |
---|
| 113 | // +-----------------------------------------------------------------------+ |
---|
| 114 | // Template |
---|
| 115 | // +-----------------------------------------------------------------------+ |
---|
| 116 | $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__).'/template/new.tpl')); |
---|
| 117 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 118 | ?> |
---|