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 | pwg_query("DELETE FROM " . CR_TABLE_2 . " WHERE `contest_id` = " . $_GET['contest_id'] .";"); |
---|
9 | |
---|
10 | foreach ($_POST['results'] AS $i => $data) { |
---|
11 | pwg_query("INSERT INTO " . CR_TABLE_2 . " |
---|
12 | ( |
---|
13 | image_id, |
---|
14 | contest_id, |
---|
15 | rank, |
---|
16 | comment, |
---|
17 | author |
---|
18 | ) |
---|
19 | VALUES( |
---|
20 | '" . $data['image_id'] ."', |
---|
21 | '" . $_GET['contest_id'] ."', |
---|
22 | '" . $data['rank'] ."', |
---|
23 | '" . $data['comment'] ."', |
---|
24 | '" . $data['author'] . "' |
---|
25 | );"); |
---|
26 | } |
---|
27 | |
---|
28 | redirect(CR_ADMIN . '&tab=results&msg=saved&contest_id=' . $_GET['contest_id']); |
---|
29 | } |
---|
30 | |
---|
31 | // +-----------------------------------------------------------------------+ |
---|
32 | // Affichage des résultats |
---|
33 | // +-----------------------------------------------------------------------+ |
---|
34 | if (isset($_GET['msg']) AND $_GET['msg'] == 'saved') |
---|
35 | array_push($page['infos'], l10n('CR_results_saved')); |
---|
36 | |
---|
37 | |
---|
38 | // Nom du concours |
---|
39 | $query = "SELECT name FROM " . CR_TABLE_1 . " WHERE id = " . $_GET['contest_id'] . ";"; |
---|
40 | $contest = pwg_db_fetch_assoc(pwg_query($query)); |
---|
41 | |
---|
42 | $template->assign(array( |
---|
43 | 'NAME' => trigger_event('render_CR_content', $contest['name']), |
---|
44 | 'CONTEST_ID' => $_GET['contest_id'] |
---|
45 | )); |
---|
46 | |
---|
47 | // Résultats |
---|
48 | $results = pwg_query("SELECT * FROM " . CR_TABLE_2 . " WHERE contest_id = " . $_GET['contest_id'] . " ORDER BY rank;"); |
---|
49 | |
---|
50 | while ($result = pwg_db_fetch_assoc($results)) { |
---|
51 | $data = array( |
---|
52 | 'RANK' => $result['rank'], |
---|
53 | 'IMAGE_ID' => $result['image_id'], |
---|
54 | 'AUTHOR' => $result['author'], |
---|
55 | 'COMMENT' => $result['comment'], |
---|
56 | ); |
---|
57 | |
---|
58 | // Infos de l'image |
---|
59 | $image = pwg_query("SELECT id, name, file, path, tn_ext |
---|
60 | FROM " . IMAGES_TABLE . " |
---|
61 | WHERE id = " . $result['image_id'] . ";"); |
---|
62 | |
---|
63 | if (!pwg_db_num_rows($image)) { |
---|
64 | $themeconf = $template->get_template_vars('themeconf'); |
---|
65 | $data['TN_SRC'] = $themeconf['admin_icon_dir'] . '/errors.png'; |
---|
66 | $data['IMAGE_NAME'] = 'N/A'; |
---|
67 | $page['errors'][] = l10n_dec('CR_id_unknown %d', 'CR_id_unknown %d', $result['image_id']); |
---|
68 | |
---|
69 | } else { |
---|
70 | $image = pwg_db_fetch_assoc($image); |
---|
71 | $data['TN_SRC'] = get_thumbnail_url($image); |
---|
72 | $data['IMAGE_NAME'] = (empty($image['name'])) ? get_name_from_file($image['file']) : $image['name']; |
---|
73 | } |
---|
74 | |
---|
75 | $template->append('results', $data); |
---|
76 | } |
---|
77 | |
---|
78 | // +-----------------------------------------------------------------------+ |
---|
79 | // Template |
---|
80 | // +-----------------------------------------------------------------------+ |
---|
81 | $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/template/results.tpl')); |
---|
82 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
83 | ?> |
---|