X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=sidebyside;f=mod%2Fmessage.php;h=40f1dd08c0d9cdc2d598e40c93f637dc198d103e;hb=f58d8f410885bb1895821cd0767bdf981629f0cd;hp=f358ba975a5c2d0807b28e202255b3c0cd31e9dd;hpb=a0530d1066d7268f1b1ea67bc3c254e9f9fc5ec8;p=friendica.git diff --git a/mod/message.php b/mod/message.php index f358ba975a..40f1dd08c0 100644 --- a/mod/message.php +++ b/mod/message.php @@ -1,214 +1,145 @@ argc >1 && is_numeric($a->argv[1])) { - $tabs = render_messages(get_messages(local_user(),0,5), 'mail_list.tpl'); + if ($a->argc > 1 && is_numeric($a->argv[1])) { + $tabs = render_messages(get_messages(local_user(), 0, 5), 'mail_list.tpl'); } - $new = array( - 'label' => t('New Message'), + $new = [ + 'label' => L10n::t('New Message'), 'url' => 'message/new', - 'sel'=> ($a->argv[1] == 'new'), + 'sel' => $a->argc > 1 && $a->argv[1] == 'new', 'accesskey' => 'm', - ); + ]; $tpl = get_markup_template('message_side.tpl'); - $a->page['aside'] = replace_macros($tpl, array( - '$tabs'=>$tabs, - '$new'=>$new, - )); + $a->page['aside'] = replace_macros($tpl, [ + '$tabs' => $tabs, + '$new' => $new, + ]); $base = System::baseUrl(); $head_tpl = get_markup_template('message-head.tpl'); - $a->page['htmlhead'] .= replace_macros($head_tpl,array( + $a->page['htmlhead'] .= replace_macros($head_tpl, [ '$baseurl' => System::baseUrl(true), '$base' => $base - )); + ]); $end_tpl = get_markup_template('message-end.tpl'); - $a->page['end'] .= replace_macros($end_tpl,array( + $a->page['end'] .= replace_macros($end_tpl, [ '$baseurl' => System::baseUrl(true), '$base' => $base - )); - + ]); } -function message_post(App $a) { - - if (! local_user()) { - notice( t('Permission denied.') . EOL); +function message_post(App $a) +{ + if (!local_user()) { + notice(L10n::t('Permission denied.') . EOL); return; } - $replyto = ((x($_REQUEST,'replyto')) ? notags(trim($_REQUEST['replyto'])) : ''); - $subject = ((x($_REQUEST,'subject')) ? notags(trim($_REQUEST['subject'])) : ''); - $body = ((x($_REQUEST,'body')) ? escape_tags(trim($_REQUEST['body'])) : ''); - $recipient = ((x($_REQUEST,'messageto')) ? intval($_REQUEST['messageto']) : 0 ); + $replyto = x($_REQUEST, 'replyto') ? notags(trim($_REQUEST['replyto'])) : ''; + $subject = x($_REQUEST, 'subject') ? notags(trim($_REQUEST['subject'])) : ''; + $body = x($_REQUEST, 'body') ? escape_tags(trim($_REQUEST['body'])) : ''; + $recipient = x($_REQUEST, 'messageto') ? intval($_REQUEST['messageto']) : 0; - $ret = send_message($recipient, $body, $subject, $replyto); + $ret = Mail::send($recipient, $body, $subject, $replyto); $norecip = false; - switch($ret){ + switch ($ret) { case -1: - notice( t('No recipient selected.') . EOL ); + notice(L10n::t('No recipient selected.') . EOL); $norecip = true; break; case -2: - notice( t('Unable to locate contact information.') . EOL ); + notice(L10n::t('Unable to locate contact information.') . EOL); break; case -3: - notice( t('Message could not be sent.') . EOL ); + notice(L10n::t('Message could not be sent.') . EOL); break; case -4: - notice( t('Message collection failure.') . EOL ); + notice(L10n::t('Message collection failure.') . EOL); break; default: - info( t('Message sent.') . EOL ); + info(L10n::t('Message sent.') . EOL); } // fake it to go back to the input form if no recipient listed - if ($norecip) { $a->argc = 2; $a->argv[1] = 'new'; - } else + } else { goaway($_SESSION['return_url']); - -} - -// Note: the code in 'item_extract_images' and 'item_redir_and_replace_images' -// is identical to the code in include/conversation.php -if (! function_exists('item_extract_images')) { -function item_extract_images($body) { - - $saved_image = array(); - $orig_body = $body; - $new_body = ''; - - $cnt = 0; - $img_start = strpos($orig_body, '[img'); - $img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false); - $img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false); - while(($img_st_close !== false) && ($img_end !== false)) { - - $img_st_close++; // make it point to AFTER the closing bracket - $img_end += $img_start; - - if (! strcmp(substr($orig_body, $img_start + $img_st_close, 5), 'data:')) { - // This is an embedded image - - $saved_image[$cnt] = substr($orig_body, $img_start + $img_st_close, $img_end - ($img_start + $img_st_close)); - $new_body = $new_body . substr($orig_body, 0, $img_start) . '[!#saved_image' . $cnt . '#!]'; - - $cnt++; - } else - $new_body = $new_body . substr($orig_body, 0, $img_end + strlen('[/img]')); - - $orig_body = substr($orig_body, $img_end + strlen('[/img]')); - - if ($orig_body === false) // in case the body ends on a closing image tag - $orig_body = ''; - - $img_start = strpos($orig_body, '[img'); - $img_st_close = ($img_start !== false ? strpos(substr($orig_body, $img_start), ']') : false); - $img_end = ($img_start !== false ? strpos(substr($orig_body, $img_start), '[/img]') : false); } +} - $new_body = $new_body . $orig_body; - - return array('body' => $new_body, 'images' => $saved_image); -}} - -if (! function_exists('item_redir_and_replace_images')) { -function item_redir_and_replace_images($body, $images, $cid) { - - $origbody = $body; - $newbody = ''; - - for($i = 0; $i < count($images); $i++) { - $search = '/\[url\=(.*?)\]\[!#saved_image' . $i . '#!\]\[\/url\]' . '/is'; - $replace = '[url=' . System::baseUrl() . '/redir/' . $cid - . '?f=1&url=' . '$1' . '][!#saved_image' . $i . '#!][/url]' ; - - $img_end = strpos($origbody, '[!#saved_image' . $i . '#!][/url]') + strlen('[!#saved_image' . $i . '#!][/url]'); - $process_part = substr($origbody, 0, $img_end); - $origbody = substr($origbody, $img_end); - - $process_part = preg_replace($search, $replace, $process_part); - $newbody = $newbody . $process_part; - } - $newbody = $newbody . $origbody; - - $cnt = 0; - foreach ($images as $image) { - // We're depending on the property of 'foreach' (specified on the PHP website) that - // it loops over the array starting from the first element and going sequentially - // to the last element - $newbody = str_replace('[!#saved_image' . $cnt . '#!]', '[img]' . $image . '[/img]', $newbody); - $cnt++; - } - - return $newbody; -}} - - - -function message_content(App $a) { - +function message_content(App $a) +{ $o = ''; - nav_set_selected('messages'); + Nav::setSelected('messages'); - if (! local_user()) { - notice( t('Permission denied.') . EOL); + if (!local_user()) { + notice(L10n::t('Permission denied.') . EOL); return; } - $myprofile = System::baseUrl().'/profile/' . $a->user['nickname']; + $myprofile = System::baseUrl() . '/profile/' . $a->user['nickname']; $tpl = get_markup_template('mail_head.tpl'); - $header = replace_macros($tpl, array( - '$messages' => t('Messages'), - '$tab_content' => $tab_content - )); - + $header = replace_macros($tpl, [ + '$messages' => L10n::t('Messages'), + ]); if (($a->argc == 3) && ($a->argv[1] === 'drop' || $a->argv[1] === 'dropconv')) { - if (! intval($a->argv[2])) + if (!intval($a->argv[2])) { return; + } // Check if we should do HTML-based delete confirmation if ($_REQUEST['confirm']) { //