The preferred method requires multiple files – one for each Page class – but the Mouse Object constructor contains only those Attributes and Attribute Options necessary for that Page class. As a result, the complete Message Mouse Object for only the Viewer Page file would look like:
class MessageDB extends DB {
function __construct() {
parent::__construct();
$g_user_object = lms_get_user_object();
$this->has(array(
message_id => array(isa => 'int',
init => $_REQUEST["message_id"],
join => array(where => "lms_message.message_id = ? AND " .
'(lms_message.from_user_id = ' . $g_user_object->user_id .
' OR lms_message.to_user_id = ' . $g_user_object->user_id . ')')),
subject => array(isa => 'Str32'),
message => array(isa => 'Text',
name => "Message",
row => 2,
col => 1),
from_user_id => array(name => 'From',
isa => 'Username',
join => array(table => 'lms_user lu_from',
column => 'lu_from.username',
where => 'lu_from.user_id = lms_message.from_user_id'),
row => 1,
col => 1),
to_user_id => array(name => 'To',
isa => 'Username',
join => array(table => 'lms_user lu_to',
column => 'lu_to.username',
where => 'lu_to.user_id = lms_message.to_user_id'),
row => 1,
col => 2),
sent_date_time => array(name => 'Time Sent',
isa => 'DateTime',
order => 'desc',
row => 3,
col => 1),
read_date_time => array(isa => 'DateTime',
name => 'Time Read',
row => 3,
col => 2,
join => array(column => "IF(lms_message.read_date_time=” .
“0,NOW(),lms_message.read_date_time)"))
));
}
function update_message_read_time() {
try {
$sql = "UPDATE lms_message SET read_date_time = NOW() where message_id = ? and read_date_time in (0,null)";
$bind_vars = array(array('value' => $this->get_message_id(), 'type' => 'i'));
if ($stmt = $this->db_prepare($sql, $bind_vars)) {
$stmt->execute();
}
} catch (Exception $e) {
print($e->getMessage());
}
}
Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer