X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fmessage.php;h=4bd73d0cee9d36da73e625d467457843d4a4fe2a;hb=8f6e9fa65e252b4b630642ccdbccb06f35ab176f;hp=8108ff96bdc6dde958f04c4f7524c7c19d4e3267;hpb=8e0b3b28dab6f13f0f6184e1d5dd5346bf7bb2f1;p=friendica.git diff --git a/mod/message.php b/mod/message.php index 8108ff96bd..4bd73d0cee 100644 --- a/mod/message.php +++ b/mod/message.php @@ -9,7 +9,7 @@ function message_init(&$a) { $tabs = ''; if ($a->argc >1 && is_numeric($a->argv[1])) { - $tabs = render_messages(get_messages(local_user(),0,5), 'mail_list.tpl'); + $tabs = render_messages(get_messages(local_user(),0,5), 'mail_list.tpl'); } $new = array( @@ -305,15 +305,29 @@ function message_content(&$a) { $prename = $preurl = $preid = ''; if($preselect) { - $r = q("select name, url, id from contact where uid = %d and id = %d limit 1", + $r = q("SELECT `name`, `url`, `id` FROM `contact` WHERE `uid` = %d AND `id` = %d LIMIT 1", intval(local_user()), intval($a->argv[2]) ); + if(!$r) { + $r = q("SELECT `name`, `url`, `id` FROM `contact` WHERE `uid` = %d AND `nurl` = '%s' LIMIT 1", + intval(local_user()), + dbesc(normalise_link(base64_decode($a->argv[2]))) + ); + } + if(!$r) { + $r = q("SELECT `name`, `url`, `id` FROM `contact` WHERE `uid` = %d AND `addr` = '%s' LIMIT 1", + intval(local_user()), + dbesc(base64_decode($a->argv[2])) + ); + } if(count($r)) { $prename = $r[0]['name']; $preurl = $r[0]['url']; $preid = $r[0]['id']; - } + $preselect = array($preid); + } else + $preselect = false; } $prefill = (($preselect) ? $prename : ''); @@ -342,7 +356,6 @@ function message_content(&$a) { '$wait' => t('Please wait'), '$submit' => t('Submit') )); - return $o; } @@ -360,11 +373,13 @@ function message_content(&$a) { intval(local_user()) ); - if(count($r)) $a->set_pager_total($r[0]['total']); + if (dbm::is_result($r)) { + $a->set_pager_total($r[0]['total']); + } $r = get_messages(local_user(), $a->pager['start'], $a->pager['itemspage']); - if(! count($r)) { + if(! dbm::is_result($r)) { info( t('No messages.') . EOL); return $o; } @@ -446,9 +461,11 @@ function message_content(&$a) { if($message['from-url'] == $myprofile) { $from_url = $myprofile; $sparkle = ''; - } - else { - $from_url = 'redir/' . $message['contact-id']; + } elseif ($message['contact-id'] != 0) { + $from_url = 'redir/'.$message['contact-id']; + $sparkle = ' sparkle'; + } else { + $from_url = $message['from-url']."?zrl=".urlencode($myprofile); $sparkle = ' sparkle'; } @@ -462,20 +479,25 @@ function message_content(&$a) { $subject_e = template_escape($message['title']); $body_e = template_escape(Smilies::replace(bbcode($message['body']))); $to_name_e = template_escape($message['name']); - } - else { + } else { $from_name_e = $message['from-name']; $subject_e = $message['title']; $body_e = Smilies::replace(bbcode($message['body'])); $to_name_e = $message['name']; } + $contact = get_contact_details_by_url($message['from-url']); + if (isset($contact["thumb"])) + $from_photo = $contact["thumb"]; + else + $from_photo = $message['from-photo']; + $mails[] = array( 'id' => $message['id'], 'from_name' => $from_name_e, 'from_url' => $from_url, 'sparkle' => $sparkle, - 'from_photo' => $message['from-photo'], + 'from_photo' => proxy_url($from_photo, false, PROXY_SIZE_THUMB), 'subject' => $subject_e, 'body' => $body_e, 'delete' => t('Delete message'), @@ -542,7 +564,7 @@ function get_messages($user, $lstart, $lend) { ); } -function render_messages($msg, $t) { +function render_messages(array $msg, $t) { $a = get_app(); @@ -571,12 +593,18 @@ function render_messages($msg, $t) { $to_name_e = $rr['name']; } + $contact = get_contact_details_by_url($rr['url']); + if (isset($contact["thumb"])) + $from_photo = $contact["thumb"]; + else + $from_photo = (($rr['thumb']) ? $rr['thumb'] : $rr['from-photo']); + $rslt .= replace_macros($tpl, array( '$id' => $rr['id'], '$from_name' => $participants, '$from_url' => (($rr['network'] === NETWORK_DFRN) ? 'redir/' . $rr['contact-id'] : $rr['url']), '$sparkle' => ' sparkle', - '$from_photo' => (($rr['thumb']) ? $rr['thumb'] : $rr['from-photo']), + '$from_photo' => proxy_url($from_photo, false, PROXY_SIZE_THUMB), '$subject' => $subject_e, '$delete' => t('Delete conversation'), '$body' => $body_e,