[9421] | 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['content'] == null) { |
---|
| 11 | array_push($page['errors'], l10n('AM_empty_content')); |
---|
| 12 | |
---|
| 13 | } else { |
---|
[9786] | 14 | if (isset($_GET['message_id'])) { |
---|
| 15 | pwg_query("UPDATE `". AM_TABLE ."` SET |
---|
| 16 | `author` = '". $_POST['username'] ."', |
---|
| 17 | `content` = '". $_POST['content'] ."' |
---|
| 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['content'] ."' |
---|
| 29 | );"); |
---|
| 30 | } |
---|
[9421] | 31 | |
---|
| 32 | if (isset($_GET['redirect']) AND $_GET['redirect'] = 'home') |
---|
[9786] | 33 | redirect(get_root_url() . 'admin.php#messages'); |
---|
[9421] | 34 | else |
---|
[9786] | 35 | redirect(AM_ADMIN .'-list&msg=added'); |
---|
[9421] | 36 | } |
---|
| 37 | } |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | // +-----------------------------------------------------------------------+ |
---|
| 41 | // Formulaire vierge |
---|
| 42 | // +-----------------------------------------------------------------------+ |
---|
[9786] | 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)); |
---|
[9421] | 46 | |
---|
[9786] | 47 | $template->assign(array( |
---|
| 48 | 'USERNAME' => $message['author'], |
---|
| 49 | 'CONTENT' => $message['content'], |
---|
| 50 | 'FREE_NAME' => (!$conf['admin_messages']['free_name']) ? 'disabled="disabled"' : '', |
---|
| 51 | )); |
---|
[9421] | 52 | |
---|
[9786] | 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 | |
---|
[9421] | 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 | ?> |
---|