source: extensions/ContestResults/admin/results.php @ 6782

Last change on this file since 6782 was 6782, checked in by mistic100, 14 years ago

Fixs some errors. Add results previews. Code revision.

File size: 2.7 KB
Line 
1<?php
2if(!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4// +-----------------------------------------------------------------------+
5//                      Modification des résultats
6// +-----------------------------------------------------------------------+
7if(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//                      Affichage des résultats
28// +-----------------------------------------------------------------------+
29$query = "SELECT name FROM " . CR_TABLE_1 . " WHERE id = " . $_GET['contest_id'] . ";";
30$contest = pwg_db_fetch_assoc(pwg_query($query));
31$template->assign(array(
32        'NAME' => trigger_event('render_CR_content', $contest['name']),
33        'CONTEST_ID' => $_GET['contest_id']
34));
35
36$query = "SELECT * FROM " . CR_TABLE_2 . " WHERE contest_id = " . $_GET['contest_id'] . " ORDER BY rank;";
37$results = pwg_query($query);
38
39while($result = pwg_db_fetch_assoc($results)){
40        $data = array(
41                'RANK' => $result['rank'],
42                'IMAGE_ID' => $result['image_id'],
43                'AUTHOR' => $result['author'],
44                'COMMENT' => $result['comment'],
45                'U_DELETE' => CR_ADMIN . '&tab=results&contest_id=' . $_GET['contest_id'] . '&delete_result=' . $result['image_id'],
46        );
47       
48        // Infos de l'image
49        $query = "SELECT id, name, file, path, tn_ext
50                FROM " . IMAGES_TABLE . "
51                WHERE id = " . $result['image_id'] . ";";
52        $image = pwg_query($query);
53       
54        if(!pwg_db_num_rows($image)){
55                $themeconf = $template->get_template_vars('themeconf');
56                $data['TN_SRC'] = $themeconf['admin_icon_dir'] . '/errors.png';
57                $data['IMAGE_NAME'] = 'N/A';
58                $page['errors'][] = l10n_dec('CR_id_unknown %d', 'CR_id_unknown %d', $result['image_id']);
59        }else{
60                $image = pwg_db_fetch_assoc($image);
61                $data['TN_SRC'] = get_thumbnail_url($image);
62                $data['IMAGE_NAME'] = (empty($image['name'])) ? get_name_from_file($image['file']) : $image['name'];
63        }
64       
65        $template->append('results', $data);
66}
67
68// +-----------------------------------------------------------------------+
69//                              Template
70// +-----------------------------------------------------------------------+
71$template->set_filenames(array('plugin_admin_content' => dirname(__FILE__) . '/template/results.tpl'));
72$template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content');
73?>
Note: See TracBrowser for help on using the repository browser.