1 | <?php |
---|
2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
3 | |
---|
4 | // +-----------------------------------------------------------------------+ |
---|
5 | // Ajout d'un message |
---|
6 | // +-----------------------------------------------------------------------+ |
---|
7 | if (isset($_POST['new_submit'])) { |
---|
8 | if ($_POST['username'] == null) $_POST['username'] = $user['username']; |
---|
9 | |
---|
10 | if ($_POST['admin_message'] == null) { |
---|
11 | array_push($page['errors'], l10n('Content empty')); |
---|
12 | |
---|
13 | } else { |
---|
14 | if (isset($_GET['message_id'])) { |
---|
15 | pwg_query("UPDATE `". AM_TABLE ."` SET |
---|
16 | `author` = '". $_POST['username'] ."', |
---|
17 | `content` = '". $_POST['admin_message'] ."' |
---|
18 | WHERE `id` = ". $_GET['message_id'] .";"); |
---|
19 | } else { |
---|
20 | pwg_query("INSERT INTO `". AM_TABLE ."`( |
---|
21 | add_date, |
---|
22 | author, |
---|
23 | content |
---|
24 | ) |
---|
25 | VALUES( |
---|
26 | '". date('Y-m-d H:i:s') ."', |
---|
27 | '". $_POST['username'] ."', |
---|
28 | '". $_POST['admin_message'] ."' |
---|
29 | );"); |
---|
30 | } |
---|
31 | |
---|
32 | if (isset($_GET['redirect']) AND $_GET['redirect'] = 'home') |
---|
33 | redirect(get_root_url() . 'admin.php#messages'); |
---|
34 | else |
---|
35 | redirect(AM_ADMIN .'-list&msg=added'); |
---|
36 | } |
---|
37 | } |
---|
38 | |
---|
39 | |
---|
40 | // +-----------------------------------------------------------------------+ |
---|
41 | // Formulaire vierge |
---|
42 | // +-----------------------------------------------------------------------+ |
---|
43 | if (isset($_GET['message_id'])) { |
---|
44 | $query = "SELECT * FROM " . AM_TABLE . " WHERE id = " . $_GET['message_id'] . ";"; |
---|
45 | $message = pwg_db_fetch_assoc(pwg_query($query)); |
---|
46 | |
---|
47 | $template->assign(array( |
---|
48 | 'USERNAME' => $message['author'], |
---|
49 | 'CONTENT' => $message['content'], |
---|
50 | 'FREE_NAME' => (!$conf['admin_messages']['free_name']) ? 'disabled="disabled"' : '', |
---|
51 | )); |
---|
52 | |
---|
53 | } else { |
---|
54 | $template->assign(array( |
---|
55 | 'USERNAME' => $user['username'], |
---|
56 | 'CONTENT' => null, |
---|
57 | 'FREE_NAME' => (!$conf['admin_messages']['free_name']) ? 'disabled="disabled"' : '', |
---|
58 | )); |
---|
59 | } |
---|
60 | |
---|
61 | // +-----------------------------------------------------------------------+ |
---|
62 | // Template |
---|
63 | // +-----------------------------------------------------------------------+ |
---|
64 | $template->set_filenames(array('plugin_admin_content' => dirname(__FILE__).'/template/new.tpl')); |
---|
65 | $template->assign_var_from_handle('ADMIN_CONTENT', 'plugin_admin_content'); |
---|
66 | ?> |
---|