This repository has been archived on 2024-09-05. You can view files and clone it, but cannot push or open issues or pull requests.
shimmie2/ext/pm/theme.php

74 lines
2.4 KiB
PHP
Raw Normal View History

<?php
2009-10-08 16:44:25 +00:00
class PrivMsgTheme extends Themelet {
public function display_pms(Page $page, $pms) {
2010-05-28 13:26:46 +00:00
global $user;
2009-07-07 12:42:34 +00:00
$html = "
2012-03-13 07:53:41 +00:00
<table id='pms' class='zebra sortable'>
<thead><tr><th>R?</th><th>Subject</th><th>From</th><th>Date</th><th>Action</th></tr></thead>
2009-07-07 12:42:34 +00:00
<tbody>";
foreach($pms as $pm) {
2009-10-08 16:44:25 +00:00
$h_subject = html_escape($pm->subject);
if(strlen(trim($h_subject)) == 0) $h_subject = "(No subject)";
2013-09-09 12:47:42 +00:00
$from = User::by_id($pm->from_id);
$from_name = $from->name;
2009-10-08 16:44:25 +00:00
$h_from = html_escape($from_name);
$from_url = make_link("user/".url_escape($from_name));
$pm_url = make_link("pm/read/".$pm->id);
2010-05-28 13:26:46 +00:00
$del_url = make_link("pm/delete");
2009-10-08 16:44:25 +00:00
$h_date = html_escape($pm->sent_date);
$readYN = "Y";
if(!$pm->is_read) {
$h_subject = "<b>$h_subject</b>";
$readYN = "N";
}
2013-09-09 12:47:42 +00:00
$hb = $from->can("hellbanned") ? "hb" : "";
$html .= "<tr class='$hb'>
<td>$readYN</td>
<td><a href='$pm_url'>$h_subject</a></td>
<td><a href='$from_url'>$h_from</a></td><td>$h_date</td>
2010-05-28 13:26:46 +00:00
<td><form action='$del_url' method='POST'>
<input type='hidden' name='pm_id' value='{$pm->id}'>
".$user->get_auth_html()."
2009-07-19 03:48:25 +00:00
<input type='submit' value='Delete'>
</form></td>
</tr>";
}
2009-07-07 12:42:34 +00:00
$html .= "
</tbody>
</table>
";
2014-10-10 21:19:54 +00:00
$page->add_block(new Block("Private Messages", $html, "main", 40, "private-messages"));
}
public function display_composer(Page $page, User $from, User $to, $subject="") {
2011-01-23 11:34:27 +00:00
global $user;
$post_url = make_link("pm/send");
$h_subject = html_escape($subject);
$to_id = $to->id;
2010-05-28 13:26:46 +00:00
$auth = $user->get_auth_html();
$html = <<<EOD
<form action="$post_url" method="POST">
2010-05-28 13:26:46 +00:00
$auth
<input type="hidden" name="to_id" value="$to_id">
2012-03-13 07:53:41 +00:00
<table style="width: 400px;" class="form">
<tr><th>Subject:</th><td><input type="text" name="subject" value="$h_subject"></td></tr>
<tr><td colspan="2"><textarea style="width: 100%" rows="6" name="message"></textarea></td></tr>
<tr><td colspan="2"><input type="submit" value="Send"></td></tr>
</table>
</form>
EOD;
2014-10-10 21:19:54 +00:00
$page->add_block(new Block("Write a PM", $html, "main", 50));
}
2009-10-08 16:44:25 +00:00
public function display_message(Page $page, User $from, User $to, PM $pm) {
$this->display_composer($page, $to, $from, "Re: ".$pm->subject);
$page->set_title("Private Message");
2009-10-08 16:44:25 +00:00
$page->set_heading(html_escape($pm->subject));
$page->add_block(new NavBlock());
2012-06-10 17:18:50 +00:00
$page->add_block(new Block("Message from {$from->name}", format_text($pm->message), "main", 10));
}
}