diff options
| author | Michael Save <savetheinternet@tinyboard.org> | 2012-04-13 22:00:40 +1000 |
|---|---|---|
| committer | Michael Save <savetheinternet@tinyboard.org> | 2012-04-13 22:00:40 +1000 |
| commit | e49ece459e2ee225ba677f8e0758a38a98b930f5 (patch) | |
| tree | 3e40bf21f531294fca7a42e44ef4855b33cfd277 /inc | |
| parent | 761cb4feab1a052e2e611a1d09d0a3513e011c06 (diff) | |
new PM
Diffstat (limited to 'inc')
| -rw-r--r-- | inc/mod/auth.php | 13 | ||||
| -rw-r--r-- | inc/mod/pages.php | 33 |
2 files changed, 44 insertions, 2 deletions
diff --git a/inc/mod/auth.php b/inc/mod/auth.php index 2e90b757..f9b863c8 100644 --- a/inc/mod/auth.php +++ b/inc/mod/auth.php @@ -122,3 +122,16 @@ if (isset($_COOKIE[$config['cookies']['mod']])) { ); } +function create_pm_header() { + global $mod; + $query = prepare("SELECT `id` FROM `pms` WHERE `to` = :id AND `unread` = 1"); + $query->bindValue(':id', $mod['id'], PDO::PARAM_INT); + $query->execute() or error(db_error($query)); + + if ($pm = $query->fetch()) { + return Array('id' => $pm['id'], 'waiting' => $query->rowCount() - 1); + } + + return false; +} + diff --git a/inc/mod/pages.php b/inc/mod/pages.php index 2b5487fd..4903567a 100644 --- a/inc/mod/pages.php +++ b/inc/mod/pages.php @@ -252,13 +252,42 @@ function mod_delete($board, $post) { function mod_users() { global $config; - if(!hasPermission($config['mod']['manageusers'])) + + if (!hasPermission($config['mod']['manageusers'])) error($config['error']['noaccess']); $args = array(); $query = query("SELECT *, (SELECT `time` FROM `modlogs` WHERE `mod` = `id` ORDER BY `time` DESC LIMIT 1) AS `last`, (SELECT `text` FROM `modlogs` WHERE `mod` = `id` ORDER BY `time` DESC LIMIT 1) AS `action` FROM `mods` ORDER BY `type` DESC,`id`") or error(db_error()); $args['users'] = $query->fetchAll(PDO::FETCH_ASSOC); - mod_page("Manage users", 'mod/users.html', $args); + mod_page('Manage users', 'mod/users.html', $args); +} + +function mod_new_pm($username) { + global $config, $mod; + + if (!hasPermission($config['mod']['create_pm'])) + error($config['error']['noaccess']); + + $query = prepare("SELECT `id` FROM `mods` WHERE `username` = :username"); + $query->bindValue(':username', $username); + $query->execute() or error(db_error($query)); + if (!$id = $query->fetchColumn(0)) + error($config['error']['404']); + + if (isset($_POST['message'])) { + markup($_POST['message']); + + $query = prepare("INSERT INTO `pms` VALUES (NULL, :me, :id, :message, :time, 1)"); + $query->bindValue(':me', $mod['id']); + $query->bindValue(':id', $id); + $query->bindValue(':message', $_POST['message']); + $query->bindValue(':time', time()); + $query->execute() or error(db_error($query)); + + header('Location: ?/', true, $config['redirect_http']); + } + + mod_page("New PM for {$username}", 'mod/new_pm.html', array('username' => $username, 'id' => $id)); } |
