diff options
| author | Savetheinternet <savetheinternet@n0v4.com> | 2011-04-12 19:56:37 +1000 |
|---|---|---|
| committer | Savetheinternet <savetheinternet@n0v4.com> | 2011-04-12 19:56:37 +1000 |
| commit | 6b7786511027ca41180325e178ff0f72823b8c60 (patch) | |
| tree | 53e72a015dd6d955a97c30906f44d35a352514c6 | |
| parent | 9dc1e9870418a54f834c2e546e1c549c3662c4e8 (diff) | |
Reply to PMs with quote
| -rw-r--r-- | inc/functions.php | 10 | ||||
| -rw-r--r-- | mod.php | 25 |
2 files changed, 31 insertions, 4 deletions
diff --git a/inc/functions.php b/inc/functions.php index 5c6b7c72..9ddbb495 100644 --- a/inc/functions.php +++ b/inc/functions.php @@ -919,6 +919,16 @@ } } + function quote($body) { + $body = str_replace('<br/>', "\n", $body); + + $body = strip_tags($body); + + $body = preg_replace("/(^|\n)/", '$1>', $body); + + return $body . "\n"; + } + function markup(&$body) { global $board, $config; @@ -402,7 +402,7 @@ modLog('Read a PM'); - $body = '<form action="" method="post"><table>' . + $body = '<form action="" method="post" style="margin:0"><table>' . '<th>From</th><td>' . '<a href="?/new_PM/' . $pm['sender'] . '">' . htmlentities($pm['username']) . '</a>' . @@ -422,7 +422,9 @@ '<p style="text-align:center"><input type="submit" name="delete" value="Delete forever" /></p>' . - '</form>'; + '</form>' . + + '<p style="text-align:center"><a href="?/new_PM/' . $pm['sender'] . '/' . $pm['id'] . '">Reply with quote</a></p>'; echo Element('page.html', Array( 'config'=>$config, @@ -432,7 +434,7 @@ ) ); } - } elseif(preg_match('/^\/new_PM\/(\d+)$/', $query, $match)) { + } elseif(preg_match('/^\/new_PM\/(\d+)(\/(\d+))?$/', $query, $match)) { if($mod['type'] < $config['mod']['create_pm']) error($config['error']['noaccess']); $to = $match[1]; @@ -472,6 +474,21 @@ ) ); } else { + $value = ''; + if(isset($match[3])) { + $reply = $match[3]; + + $query = prepare("SELECT `message` FROM `pms` WHERE `sender` = :sender AND `to` = :mod AND `id` = :id"); + $query->bindValue(':sender', $to['id'], PDO::PARAM_INT); + $query->bindValue(':mod', $mod['id'], PDO::PARAM_INT); + $query->bindValue(':id', $reply, PDO::PARAM_INT); + $query->execute() or error(db_error($query)); + if($pm = $query->fetch()) { + $value = quote($pm['message']); + } + } + + $body = '<form action="" method="post">' . '<table>' . @@ -483,7 +500,7 @@ ) . '</td>' . - '<tr><th>Message</th><td><textarea name="message" rows="10" cols="40"></textarea></td>' . + '<tr><th>Message</th><td><textarea name="message" rows="10" cols="40">' . $value . '</textarea></td>' . '</table>' . |
