source: extensions/Admin_Messages/admin/new.php @ 20400

Last change on this file since 20400 was 12356, checked in by mistic100, 13 years ago

Reorganize language files

File size: 2.2 KB
RevLine 
[9421]1<?php
2if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
3
4// +-----------------------------------------------------------------------+
[12356]5//        Ajout d'un message
[9421]6// +-----------------------------------------------------------------------+
7if (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&amp;msg=added');
36  }
[9421]37}
38
39
40// +-----------------------------------------------------------------------+
[12356]41//        Formulaire vierge
[9421]42// +-----------------------------------------------------------------------+
[9786]43if (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?>
Note: See TracBrowser for help on using the repository browser.