1 | <?php |
---|
2 | if(!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // Suppression d'un concours |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | if (isset($_GET['delete_contest'])) { |
---|
8 | pwg_query('DELETE FROM ' . CR_TABLE_1 . ' WHERE id = ' . $_GET['delete_contest'] . ';'); |
---|
9 | pwg_query('DELETE FROM ' . CR_TABLE_2 . ' WHERE contest_id = ' . $_GET['delete_contest'] . ';'); |
---|
10 | redirect(CR_ADMIN .'&tab=manage&msg=deleted'); |
---|
11 | } |
---|
12 | |
---|
13 | if (isset($_GET['msg'])){ |
---|
14 | array_push($page['infos'], l10n('CR_contest_'. $_GET['msg'])); |
---|
15 | } |
---|
16 | |
---|
17 | // +-----------------------------------------------------------------------+ |
---|
18 | // Affichage des concours |
---|
19 | // +-----------------------------------------------------------------------+ |
---|
20 | $contests = pwg_query("SELECT |
---|
21 | id, |
---|
22 | name, |
---|
23 | visible, |
---|
24 | date_begin, |
---|
25 | date_end, |
---|
26 | logo |
---|
27 | FROM " . CR_TABLE_1 . " |
---|
28 | ORDER BY date_begin DESC;"); |
---|
29 | |
---|
30 | while ($contest = pwg_db_fetch_assoc($contests)) { |
---|
31 | if (is_date_passed($contest['date_end'])) { |
---|
32 | $contest['status'] = 'finished'; |
---|
33 | } else { |
---|
34 | $contest['status'] = 'pending'; |
---|
35 | } |
---|
36 | $template->append('contests_'.$contest['status'], array( |
---|
37 | 'NAME' => trigger_event('render_CR_content', $contest['name']), |
---|
38 | 'VISIBLE' => $contest['visible'], |
---|
39 | 'DATE_BEGIN' => format_date($contest['date_begin']), |
---|
40 | 'DATE_END' => format_date($contest['date_end']), |
---|
41 | 'LOGO' => $contest['logo'], |
---|
42 | 'U_RESULTS' => CR_ADMIN . '&tab=results&contest_id=' . $contest['id'], |
---|
43 | 'U_EDIT' => CR_ADMIN . '&tab=edit&contest_id=' . $contest['id'], |
---|
44 | 'U_DELETE' => CR_ADMIN . '&delete_contest=' . $contest['id'], |
---|
45 | 'URL' => CR_PUBLIC . $contest['id'] . '-' . str2url(trigger_event('render_CR_content', $contest['name'])), |
---|
46 | 'DAYS' => DateDiff($contest['date_end'],date('Y-m-d')), |
---|
47 | )); |
---|
48 | } |
---|
49 | |
---|
50 | // +-----------------------------------------------------------------------+ |
---|
51 | // Template |
---|
52 | // +-----------------------------------------------------------------------+ |
---|
53 | $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__).'/template/manage.tpl')); |
---|
54 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
55 | ?> |
---|