Using either Mouse Object constructor detailed above, a Message Viewer Page Class would look like:
class MessageViewer extends Page {
function __construct() {
parent::__construct("Message Viewer");
$this->data = new MessageDB();
$this->list = array();
}
function pre_render() {
parent::pre_render();
//handle deletes if a mission_id is presented
if ($_REQUEST['delete']) { $this->handle_delete(); }
$this->message = $this->data->read_lms_message();
if (empty($this->message)) { $this->addError("No message associated with this message ID."); }
}
function body() {
if (!empty($this->message)) {
$this->data->update_message_read_time();
$links = array(array(link => "default.php?appname=message-view&delete=1&message_id=" .
$this->data->get_message_id(), label => "Delete"));
auto_render_view($this->data, '"' . $this->data->get_subject() . '"', "600px", $links);
}
}
function handle_delete() {
$this->data->delete_lms_message();
my_redirect('default.php?appname=message-mgr');
}
}
Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer