[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'])) { |
---|
[9419] | 11 | if ($_POST['name'] != null) { |
---|
| 12 | // Modification d'un concours |
---|
| 13 | if (isset($_GET['contest_id'])) { |
---|
| 14 | pwg_query("UPDATE " . CR_TABLE_1 . " SET |
---|
| 15 | `name` = '" . $_POST['name'] ."', |
---|
| 16 | `status` = '" . $_POST['status'] ."', |
---|
| 17 | `visible` = '" . $_POST['visible'] ."', |
---|
| 18 | `date_begin` = '" . $_POST['date_begin'] ."', |
---|
| 19 | `date_end` = '" . $_POST['date_end'] ."', |
---|
| 20 | `logo` = '" . $_POST['logo'] ."', |
---|
| 21 | `banner` = '" . $_POST['banner'] ."', |
---|
| 22 | `summary` = '" . $_POST['summary'] ."', |
---|
| 23 | `presentation` = '" . $_POST['presentation'] ."', |
---|
| 24 | `rules` = '" . $_POST['rules'] ."', |
---|
| 25 | `prices` = '" . $_POST['prices'] ."', |
---|
| 26 | `final` = '" . $_POST['final'] ."' |
---|
| 27 | WHERE `id` = " . $_GET['contest_id'] .";"); |
---|
| 28 | |
---|
| 29 | // redirige vers la page du concours si on en viens |
---|
| 30 | if (isset($_GET['redirect']) AND $_GET['redirect'] == 'page') { |
---|
| 31 | redirect(CR_PUBLIC . $_GET['contest_id'] . '-' . str2url(trigger_event('render_CR_content', $_POST['name']))); |
---|
| 32 | } else { |
---|
| 33 | redirect(CR_ADMIN .'&tab=manage&msg=saved'); |
---|
| 34 | } |
---|
| 35 | |
---|
| 36 | // Ajout d'un concours |
---|
[9200] | 37 | } else { |
---|
[9419] | 38 | pwg_query("INSERT INTO " . CR_TABLE_1 . " |
---|
| 39 | ( |
---|
| 40 | name, |
---|
| 41 | date_begin, |
---|
| 42 | date_end, |
---|
| 43 | status, |
---|
| 44 | visible, |
---|
| 45 | logo, |
---|
| 46 | banner, |
---|
| 47 | summary, |
---|
| 48 | presentation, |
---|
| 49 | rules, |
---|
| 50 | prices, |
---|
| 51 | final |
---|
| 52 | ) |
---|
| 53 | VALUES( |
---|
| 54 | '" . $_POST['name'] ."', |
---|
| 55 | '" . $_POST['date_begin'] ."', |
---|
| 56 | '" . $_POST['date_end'] ."', |
---|
| 57 | '" . $_POST['status'] ."', |
---|
| 58 | '" . $_POST['visible'] ."', |
---|
| 59 | '" . $_POST['logo'] ."', |
---|
| 60 | '" . $_POST['banner'] ."', |
---|
| 61 | '" . $_POST['summary'] ."', |
---|
| 62 | '" . $_POST['presentation'] ."', |
---|
| 63 | '" . $_POST['rules'] ."', |
---|
| 64 | '" . $_POST['prices'] ."', |
---|
| 65 | '" . $_POST['final'] ."' |
---|
| 66 | );"); |
---|
| 67 | redirect(CR_ADMIN .'&tab=manage&msg=added'); |
---|
[9200] | 68 | } |
---|
[6768] | 69 | |
---|
[9200] | 70 | } else { |
---|
[9419] | 71 | array_push($page['errors'], l10n('CR_name_empty')); |
---|
[6768] | 72 | } |
---|
| 73 | } |
---|
| 74 | |
---|
| 75 | |
---|
| 76 | // +-----------------------------------------------------------------------+ |
---|
[9200] | 77 | // Définition des variables template |
---|
[9419] | 78 | // +-----------------------------------------------------------------------+ |
---|
| 79 | // Formulaire incomplet |
---|
| 80 | if ($page['errors']) { |
---|
| 81 | $template->assign(array( |
---|
| 82 | 'NAME' => $_POST['name'], |
---|
| 83 | 'STATUS' => $_POST['status'], |
---|
| 84 | 'VISIBLE' => $_POST['visible'], |
---|
| 85 | 'DATE_BEGIN' => $_POST['date_begin'], |
---|
| 86 | 'DATE_END' => $_POST['date_end'], |
---|
| 87 | 'LOGO' => $_POST['logo'], |
---|
| 88 | 'BANNER' => $_POST['banner'], |
---|
| 89 | 'SUMMARY' => $_POST['summary'], |
---|
| 90 | )); |
---|
| 91 | |
---|
| 92 | foreach ($textareas AS $key) { |
---|
| 93 | $template->assign(strtoupper($key), $_POST[$key]); |
---|
| 94 | } |
---|
| 95 | |
---|
[6768] | 96 | // Edition d'un concours |
---|
[9419] | 97 | } else if (isset($_GET['contest_id'])) { |
---|
[6768] | 98 | $query = "SELECT * FROM " . CR_TABLE_1 . " WHERE id = " . $_GET['contest_id'] . ";"; |
---|
| 99 | $contest = pwg_db_fetch_assoc(pwg_query($query)); |
---|
| 100 | |
---|
| 101 | $template->assign(array( |
---|
| 102 | 'ID' => $contest['id'], |
---|
| 103 | 'NAME' => $contest['name'], |
---|
| 104 | 'STATUS' => $contest['status'], |
---|
| 105 | 'VISIBLE' => $contest['visible'], |
---|
| 106 | 'DATE_BEGIN' => $contest['date_begin'], |
---|
| 107 | 'DATE_END' => $contest['date_end'], |
---|
| 108 | 'LOGO' => $contest['logo'], |
---|
| 109 | 'BANNER' => $contest['banner'], |
---|
| 110 | 'SUMMARY' => $contest['summary'], |
---|
| 111 | )); |
---|
| 112 | |
---|
[9200] | 113 | foreach ($textareas AS $key) { |
---|
[6768] | 114 | $template->assign(strtoupper($key), $contest[$key]); |
---|
| 115 | } |
---|
| 116 | |
---|
| 117 | // Ajout d'un concours |
---|
[9200] | 118 | } else { |
---|
[6768] | 119 | $template->assign(array( |
---|
| 120 | 'NAME' => null, |
---|
| 121 | 'STATUS' => 'pending', |
---|
| 122 | 'VISIBLE' => 1, |
---|
| 123 | 'DATE_BEGIN' => date('Y-m-d'), |
---|
| 124 | 'DATE_END' => date('Y-m-d', time()+2592000), |
---|
| 125 | 'LOGO' => null, |
---|
| 126 | 'BANNER' => null, |
---|
| 127 | 'SUMMARY' => null, |
---|
| 128 | )); |
---|
| 129 | |
---|
[9200] | 130 | foreach ($textareas AS $key) { |
---|
| 131 | $template->assign(strtoupper($key), null); |
---|
[6768] | 132 | } |
---|
| 133 | } |
---|
| 134 | |
---|
| 135 | // +-----------------------------------------------------------------------+ |
---|
| 136 | // Template |
---|
| 137 | // +-----------------------------------------------------------------------+ |
---|
| 138 | $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__).'/template/new.tpl')); |
---|
| 139 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
| 140 | ?> |
---|