X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fmessage.php;h=b414fe0e49f6110371dbeb6a6c7bec1a0a533f8f;hb=0360f7197aac062eb2fecf95969658ca56068deb;hp=8940ee44b7832f207d8cb188298c069c6d1b71c1;hpb=724a58e79a664b65a3b68a4e3eb7fc88e1958af5;p=friendica.git diff --git a/mod/message.php b/mod/message.php index 8940ee44b7..b414fe0e49 100644 --- a/mod/message.php +++ b/mod/message.php @@ -6,6 +6,8 @@ use Friendica\App; use Friendica\Content\Nav; use Friendica\Content\Smilies; +use Friendica\Content\Text\BBCode; +use Friendica\Core\ACL; use Friendica\Core\L10n; use Friendica\Core\System; use Friendica\Database\DBM; @@ -14,7 +16,6 @@ use Friendica\Model\Mail; use Friendica\Util\DateTimeFormat; use Friendica\Util\Temporal; -require_once 'include/acl_selectors.php'; require_once 'include/conversation.php'; function message_init(App $a) @@ -117,7 +118,7 @@ function message_content(App $a) } // Check if we should do HTML-based delete confirmation - if ($_REQUEST['confirm']) { + if (!empty($_REQUEST['confirm'])) { //
can't take arguments in its "action" parameter // so add any arguments as hidden inputs $query = explode_querystring($a->query_string); @@ -140,20 +141,18 @@ function message_content(App $a) '$cancel' => L10n::t('Cancel'), ]); } + // Now check how the user responded to the confirmation query - if ($_REQUEST['canceled']) { + if (!empty($_REQUEST['canceled'])) { goaway($_SESSION['return_url']); } $cmd = $a->argv[1]; if ($cmd === 'drop') { - $r = q("DELETE FROM `mail` WHERE `id` = %d AND `uid` = %d LIMIT 1", - intval($a->argv[2]), - intval(local_user()) - ); - if ($r) { + if (dba::delete('mail', ['id' => $a->argv[2], 'uid' => local_user()])) { info(L10n::t('Message deleted.') . EOL); } + //goaway(System::baseUrl(true) . '/message' ); goaway($_SESSION['return_url']); } else { @@ -165,22 +164,7 @@ function message_content(App $a) $parent = $r[0]['parent-uri']; $convid = $r[0]['convid']; - $r = q("DELETE FROM `mail` WHERE `parent-uri` = '%s' AND `uid` = %d ", - dbesc($parent), - intval(local_user()) - ); - - // remove diaspora conversation pointer - // Actually if we do this, we can never receive another reply to that conversation, - // as we will never again have the info we need to re-create it. - // We'll just have to orphan it. - //if ($convid) { - // q("delete from conv where id = %d limit 1", - // intval($convid) - // ); - //} - - if ($r) { + if (dba::delete('mail', ['parent-uri' => $parent, 'uid' => local_user()])) { info(L10n::t('Conversation removed.') . EOL); } } @@ -206,7 +190,7 @@ function message_content(App $a) '$linkurl' => L10n::t('Please enter a link URL:') ]); - $preselect = isset($a->argv[2]) ? [$a->argv[2]] : false; + $preselect = isset($a->argv[2]) ? [$a->argv[2]] : []; $prename = $preurl = $preid = ''; @@ -235,14 +219,14 @@ function message_content(App $a) $preid = $r[0]['id']; $preselect = [$preid]; } else { - $preselect = false; + $preselect = []; } } $prefill = $preselect ? $prename : ''; // the ugly select box - $select = contact_select('messageto', 'message-to-select', $preselect, 4, true, false, false, 10); + $select = ACL::getMessageContactSelectHTML('messageto', 'message-to-select', $preselect, 4, 10); $tpl = get_markup_template('prv_message.tpl'); $o .= replace_macros($tpl, [ @@ -324,8 +308,10 @@ function message_content(App $a) WHERE `mail`.`uid` = %d $sql_extra ORDER BY `mail`.`created` ASC", intval(local_user()) ); + } else { + $messages = false; } - if (!count($messages)) { + if (!DBM::is_result($messages)) { notice(L10n::t('Message not available.') . EOL); return $o; } @@ -335,8 +321,6 @@ function message_content(App $a) intval(local_user()) ); - require_once("include/bbcode.php"); - $tpl = get_markup_template('msg-header.tpl'); $a->page['htmlhead'] .= replace_macros($tpl, [ '$baseurl' => System::baseUrl(true), @@ -361,11 +345,8 @@ function message_content(App $a) if ($message['from-url'] == $myprofile) { $from_url = $myprofile; $sparkle = ''; - } elseif ($message['contact-id'] != 0) { - $from_url = 'redir/' . $message['contact-id']; - $sparkle = ' sparkle'; } else { - $from_url = $message['from-url'] . "?zrl=" . urlencode($myprofile); + $from_url = Contact::magicLink($message['from-url']); $sparkle = ' sparkle'; } @@ -376,7 +357,7 @@ function message_content(App $a) $from_name_e = $message['from-name']; $subject_e = $message['title']; - $body_e = Smilies::replace(bbcode($message['body'])); + $body_e = Smilies::replace(BBCode::convert($message['body'])); $to_name_e = $message['name']; $contact = Contact::getDetailsByURL($message['from-url']); @@ -397,7 +378,7 @@ function message_content(App $a) 'body' => $body_e, 'delete' => L10n::t('Delete message'), 'to_name' => $to_name_e, - 'date' => DateTimeFormat::local($message['created'], 'D, d M Y - g:i A'), + 'date' => DateTimeFormat::local($message['created'], L10n::t('D, d M Y - g:i A')), 'ago' => Temporal::getRelativeDate($message['created']), ]; @@ -490,7 +471,7 @@ function render_messages(array $msg, $t) $rslt .= replace_macros($tpl, [ '$id' => $rr['id'], '$from_name' => $participants, - '$from_url' => (($rr['network'] === NETWORK_DFRN) ? 'redir/' . $rr['contact-id'] : $rr['url']), + '$from_url' => Contact::magicLink($rr['url']), '$from_addr' => $contact['addr'], '$sparkle' => ' sparkle', '$from_photo' => proxy_url($from_photo, false, PROXY_SIZE_THUMB),