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 | // +-----------------------------------------------------------------------+ |
---|
8 | // Ajout ou modification d'un concours |
---|
9 | // +-----------------------------------------------------------------------+ |
---|
10 | if (isset($_POST['new_submit'])) { |
---|
11 | // Modification d'un concours |
---|
12 | if (isset($_GET['contest_id'])) { |
---|
13 | pwg_query("UPDATE " . CR_TABLE_1 . " SET |
---|
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'] ."', |
---|
25 | `final` = '" . $_POST['final'] ."' |
---|
26 | WHERE `id` = " . $_GET['contest_id'] .";"); |
---|
27 | |
---|
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 | } |
---|
34 | |
---|
35 | // Ajout d'un concours |
---|
36 | } else { |
---|
37 | pwg_query("INSERT INTO " . CR_TABLE_1 . " |
---|
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, |
---|
50 | final |
---|
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'] ."', |
---|
64 | '" . $_POST['final'] ."' |
---|
65 | );"); |
---|
66 | redirect(CR_ADMIN); |
---|
67 | } |
---|
68 | } |
---|
69 | |
---|
70 | |
---|
71 | // +-----------------------------------------------------------------------+ |
---|
72 | // Définition des variables template |
---|
73 | // +-----------------------------------------------------------------------+ |
---|
74 | // Edition d'un concours |
---|
75 | if (isset($_GET['contest_id'])) { |
---|
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 | |
---|
91 | foreach ($textareas AS $key) { |
---|
92 | $template->assign(strtoupper($key), $contest[$key]); |
---|
93 | } |
---|
94 | |
---|
95 | // Ajout d'un concours |
---|
96 | } else { |
---|
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 | |
---|
108 | foreach ($textareas AS $key) { |
---|
109 | $template->assign(strtoupper($key), null); |
---|
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 | ?> |
---|