1 | <?php |
---|
2 | if(!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // Modification des résultats |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | if(isset($_POST['results_modify'])){ |
---|
8 | $query = "DELETE FROM " . CR_TABLE_2 . " WHERE `contest_id` = " . $_POST['contest_id'] .";"; |
---|
9 | pwg_query($query); |
---|
10 | |
---|
11 | foreach($_POST['results'] AS $i => $data){ |
---|
12 | $query = "INSERT INTO " . CR_TABLE_2 . "(image_id, contest_id, rank, comment, author) |
---|
13 | VALUES( |
---|
14 | '" . $data['image_id'] ."', |
---|
15 | '" . $_POST['contest_id'] ."', |
---|
16 | '" . $data['rank'] ."', |
---|
17 | '" . $data['comment'] ."', |
---|
18 | '" . $data['author'] . "' |
---|
19 | );"; |
---|
20 | pwg_query($query); |
---|
21 | } |
---|
22 | |
---|
23 | redirect(CR_ADMIN . '&tab=results&contest_id=' . $_POST['contest_id']); |
---|
24 | } |
---|
25 | |
---|
26 | // +-----------------------------------------------------------------------+ |
---|
27 | // Suppression d'un résultat |
---|
28 | // +-----------------------------------------------------------------------+ |
---|
29 | if(isset($_GET['delete_result'])){ |
---|
30 | pwg_query('DELETE FROM ' . CR_TABLE_2 . ' WHERE contest_id = ' . $_GET['contest_id'] . ' AND image_id = ' . $_GET['delete_result'] . ';'); |
---|
31 | redirect(CR_ADMIN . '&tab=results&contest_id=' . $_GET['contest_id']); |
---|
32 | } |
---|
33 | |
---|
34 | // +-----------------------------------------------------------------------+ |
---|
35 | // Affichage des résultats |
---|
36 | // +-----------------------------------------------------------------------+ |
---|
37 | $query = "SELECT name FROM " . CR_TABLE_1 . " WHERE id = " . $_GET['contest_id'] . ";"; |
---|
38 | $contest = pwg_db_fetch_assoc(pwg_query($query)); |
---|
39 | $template->assign(array( |
---|
40 | 'NAME' => trigger_event('render_CR_content', $contest['name']), |
---|
41 | 'CONTEST_ID' => $_GET['contest_id'] |
---|
42 | )); |
---|
43 | |
---|
44 | $query = "SELECT * FROM " . CR_TABLE_2 . " WHERE contest_id = " . $_GET['contest_id'] . " ORDER BY rank;"; |
---|
45 | $results = pwg_query($query); |
---|
46 | |
---|
47 | while($result = pwg_db_fetch_assoc($results)){ |
---|
48 | $template->append('results', array( |
---|
49 | 'RANK' => $result['rank'], |
---|
50 | 'ID' => $result['image_id'], |
---|
51 | 'AUTHOR' => $result['author'], |
---|
52 | 'COMMENT' => $result['comment'], |
---|
53 | 'U_DELETE' => CR_ADMIN . '&tab=results&contest_id=' . $_GET['contest_id'] . '&delete_result=' . $result['image_id'], |
---|
54 | )); |
---|
55 | } |
---|
56 | |
---|
57 | // +-----------------------------------------------------------------------+ |
---|
58 | // Template |
---|
59 | // +-----------------------------------------------------------------------+ |
---|
60 | $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/template/results.tpl')); |
---|
61 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
62 | ?> |
---|