[9421] | 1 | <?php |
---|
| 2 | if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); |
---|
| 3 | |
---|
| 4 | // +-----------------------------------------------------------------------+ |
---|
[12356] | 5 | // Ajout d'un message |
---|
[9421] | 6 | // +-----------------------------------------------------------------------+ |
---|
| 7 | if (isset($_POST['new_submit'])) { |
---|
[12356] | 8 | if ($_POST['username'] == null) $_POST['username'] = $user['username']; |
---|
| 9 | |
---|
| 10 | if ($_POST['content'] == 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['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 | } |
---|
| 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 | } |
---|
[9421] | 37 | } |
---|
| 38 | |
---|
| 39 | |
---|
| 40 | // +-----------------------------------------------------------------------+ |
---|
[12356] | 41 | // Formulaire vierge |
---|
[9421] | 42 | // +-----------------------------------------------------------------------+ |
---|
[9786] | 43 | if (isset($_GET['message_id'])) { |
---|
[12356] | 44 | $query = "SELECT * FROM " . AM_TABLE . " WHERE id = " . $_GET['message_id'] . ";"; |
---|
| 45 | $message = pwg_db_fetch_assoc(pwg_query($query)); |
---|
[9421] | 46 | |
---|
[12356] | 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 { |
---|
[12356] | 54 | $template->assign(array( |
---|
| 55 | 'USERNAME' => $user['username'], |
---|
| 56 | 'CONTENT' => null, |
---|
| 57 | 'FREE_NAME' => (!$conf['admin_messages']['free_name']) ? 'disabled="disabled"' : '', |
---|
| 58 | )); |
---|
[9786] | 59 | } |
---|
| 60 | |
---|
[9421] | 61 | // +-----------------------------------------------------------------------+ |
---|
[12356] | 62 | // Template |
---|
[9421] | 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 | ?> |
---|