X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;ds=inline;f=mod%2Fmessage.php;h=3ff84a1e6684478b2200d2c552451aad2d2401c3;hb=e7be87df93895de47414a5a788cd6487adb98a29;hp=9a8a77b02bd43838f30bd1e8ae4aa720a2d15484;hpb=0f546f7f0f8b41bd7510bd3644419c002746ce34;p=friendica.git diff --git a/mod/message.php b/mod/message.php index 9a8a77b02b..3ff84a1e66 100644 --- a/mod/message.php +++ b/mod/message.php @@ -2,16 +2,24 @@ /** * @file mod/message.php */ + use Friendica\App; use Friendica\Content\Nav; +use Friendica\Content\Pager; use Friendica\Content\Smilies; +use Friendica\Content\Text\BBCode; +use Friendica\Core\ACL; +use Friendica\Core\L10n; +use Friendica\Core\Renderer; use Friendica\Core\System; -use Friendica\Database\DBM; +use Friendica\Database\DBA; use Friendica\Model\Contact; use Friendica\Model\Mail; - -require_once 'include/acl_selectors.php'; -require_once 'include/conversation.php'; +use Friendica\Module\Login; +use Friendica\Util\DateTimeFormat; +use Friendica\Util\Proxy as ProxyUtils; +use Friendica\Util\Strings; +use Friendica\Util\Temporal; function message_init(App $a) { @@ -22,27 +30,21 @@ function message_init(App $a) } $new = [ - 'label' => t('New Message'), + 'label' => L10n::t('New Message'), 'url' => 'message/new', 'sel' => $a->argc > 1 && $a->argv[1] == 'new', 'accesskey' => 'm', ]; - $tpl = get_markup_template('message_side.tpl'); - $a->page['aside'] = replace_macros($tpl, [ + $tpl = Renderer::getMarkupTemplate('message_side.tpl'); + $a->page['aside'] = Renderer::replaceMacros($tpl, [ '$tabs' => $tabs, '$new' => $new, ]); $base = System::baseUrl(); - $head_tpl = get_markup_template('message-head.tpl'); - $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, [ + $head_tpl = Renderer::getMarkupTemplate('message-head.tpl'); + $a->page['htmlhead'] .= Renderer::replaceMacros($head_tpl, [ '$baseurl' => System::baseUrl(true), '$base' => $base ]); @@ -51,34 +53,34 @@ function message_init(App $a) function message_post(App $a) { if (!local_user()) { - notice(t('Permission denied.') . EOL); + 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 = !empty($_REQUEST['replyto']) ? Strings::escapeTags(trim($_REQUEST['replyto'])) : ''; + $subject = !empty($_REQUEST['subject']) ? Strings::escapeTags(trim($_REQUEST['subject'])) : ''; + $body = !empty($_REQUEST['body']) ? Strings::escapeHtml(trim($_REQUEST['body'])) : ''; + $recipient = !empty($_REQUEST['messageto']) ? intval($_REQUEST['messageto']) : 0; $ret = Mail::send($recipient, $body, $subject, $replyto); $norecip = false; 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 @@ -86,7 +88,7 @@ function message_post(App $a) $a->argc = 2; $a->argv[1] = 'new'; } else { - goaway($_SESSION['return_url']); + $a->internalRedirect($a->cmd . '/' . $ret); } } @@ -96,15 +98,30 @@ function message_content(App $a) Nav::setSelected('messages'); if (!local_user()) { - notice(t('Permission denied.') . EOL); - return; + notice(L10n::t('Permission denied.') . EOL); + return Login::form(); } $myprofile = System::baseUrl() . '/profile/' . $a->user['nickname']; - $tpl = get_markup_template('mail_head.tpl'); - $header = replace_macros($tpl, [ - '$messages' => t('Messages'), + $tpl = Renderer::getMarkupTemplate('mail_head.tpl'); + if ($a->argc > 1 && $a->argv[1] == 'new') { + $button = [ + 'label' => L10n::t('Discard'), + 'url' => '/message', + 'sel' => 'close', + ]; + } else { + $button = [ + 'label' => L10n::t('New Message'), + 'url' => '/message/new', + 'sel' => 'new', + 'accesskey' => 'm', + ]; + } + $header = Renderer::replaceMacros($tpl, [ + '$messages' => L10n::t('Messages'), + '$button' => $button, ]); if (($a->argc == 3) && ($a->argv[1] === 'drop' || $a->argv[1] === 'dropconv')) { @@ -113,7 +130,7 @@ function message_content(App $a) } // Check if we should do HTML-based delete confirmation - if ($_REQUEST['confirm']) { + if (!empty($_REQUEST['confirm'])) { //