+ if(($a->argc > 1) && (intval($a->argv[1]))) {
+
+ $o .= $header;
+
+ $r = q("SELECT `mail`.*, `contact`.`name`, `contact`.`url`, `contact`.`thumb`
+ FROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id`
+ WHERE `mail`.`uid` = %d AND `mail`.`id` = %d LIMIT 1",
+ intval(local_user()),
+ intval($a->argv[1])
+ );
+ if(count($r)) {
+ $contact_id = $r[0]['contact-id'];
+ $messages = q("SELECT `mail`.*, `contact`.`name`, `contact`.`url`, `contact`.`thumb`
+ FROM `mail` LEFT JOIN `contact` ON `mail`.`contact-id` = `contact`.`id`
+ WHERE `mail`.`uid` = %d AND `mail`.`parent-uri` = '%s' ORDER BY `mail`.`created` ASC",
+ intval(local_user()),
+ dbesc($r[0]['parent-uri'])
+ );
+ }
+ if(! count($messages)) {
+ notice( t('Message not available.') . EOL );
+ return $o;
+ }
+
+ $r = q("UPDATE `mail` SET `seen` = 1 WHERE `parent-uri` = '%s' AND `uid` = %d",
+ dbesc($r[0]['parent-uri']),
+ intval(local_user())
+ );
+
+ require_once("include/bbcode.php");
+
+ $tpl = load_view_file('view/msg-header.tpl');
+
+ $a->page['htmlhead'] .= replace_macros($tpl, array(
+ '$nickname' => $a->user['nickname'],
+ '$baseurl' => $a->get_baseurl()
+ ));
+
+
+ $tpl = load_view_file('view/mail_conv.tpl');
+ foreach($messages as $message) {
+ if($message['from-url'] == $myprofile) {
+ $from_url = $myprofile;
+ $sparkle = '';
+ }
+ else {
+ $from_url = $a->get_baseurl() . '/redir/' . $message['contact-id'];
+ $sparkle = ' sparkle';
+ }
+ $o .= replace_macros($tpl, array(
+ '$id' => $message['id'],
+ '$from_name' =>$message['from-name'],
+ '$from_url' => $from_url,
+ '$sparkle' => $sparkle,
+ '$from_photo' => $message['from-photo'],
+ '$subject' => $message['title'],
+ '$body' => smilies(bbcode($message['body'])),
+ '$delete' => t('Delete message'),
+ '$to_name' => $message['name'],
+ '$date' => datetime_convert('UTC',date_default_timezone_get(),$message['created'],'D, d M Y - g:i A')
+ ));
+
+ }
+ $select = $message['name'] . '<input type="hidden" name="messageto" value="' . $contact_id . '" />';
+ $parent = '<input type="hidden" name="replyto" value="' . $message['parent-uri'] . '" />';
+ $tpl = load_view_file('view/prv_message.tpl');
+ $o .= replace_macros($tpl,array(
+ '$header' => t('Send Reply'),
+ '$to' => t('To:'),
+ '$subject' => t('Subject:'),
+ '$subjtxt' => $message['title'],
+ '$readonly' => ' readonly="readonly" style="background: #BBBBBB;" ',
+ '$yourmessage' => t('Your message:'),
+ '$select' => $select,
+ '$parent' => $parent,
+ '$upload' => t('Upload photo'),
+ '$insert' => t('Insert web link'),
+ '$wait' => t('Please wait')
+
+ ));
+
+ return $o;
+ }
+