X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fmessage.php;h=726db0a754a6002d9b110726e80120895e958899;hb=194b84141d8101bb34eba37586c3afcb6f0b871b;hp=6a48eb658e523317e7e7f681fb9f27e6a1b5cfd1;hpb=eecd1e47e4752f6a71f944455dd95fc837683cad;p=friendica.git diff --git a/mod/message.php b/mod/message.php index 6a48eb658e..726db0a754 100644 --- a/mod/message.php +++ b/mod/message.php @@ -1,97 +1,107 @@ . + * */ use Friendica\App; use Friendica\Content\Nav; -use Friendica\Content\Smilies; +use Friendica\Content\Pager; use Friendica\Content\Text\BBCode; use Friendica\Core\ACL; -use Friendica\Core\L10n; -use Friendica\Core\System; -use Friendica\Database\DBM; +use Friendica\Core\Renderer; +use Friendica\Database\DBA; +use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Mail; +use Friendica\Module\Security\Login; use Friendica\Util\DateTimeFormat; +use Friendica\Util\Strings; use Friendica\Util\Temporal; -require_once 'include/conversation.php'; - function message_init(App $a) { $tabs = ''; - if ($a->argc > 1 && is_numeric($a->argv[1])) { - $tabs = render_messages(get_messages(local_user(), 0, 5), 'mail_list.tpl'); + if (DI::args()->getArgc() > 1 && is_numeric(DI::args()->getArgv()[1])) { + $tabs = render_messages(get_messages(DI::userSession()->getLocalUserId(), 0, 5), 'mail_list.tpl'); } $new = [ - 'label' => L10n::t('New Message'), - 'url' => 'message/new', - 'sel' => $a->argc > 1 && $a->argv[1] == 'new', + 'label' => DI::l10n()->t('New Message'), + 'url' => 'message/new', + 'sel' => DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'new', 'accesskey' => 'm', ]; - $tpl = get_markup_template('message_side.tpl'); - $a->page['aside'] = replace_macros($tpl, [ + $tpl = Renderer::getMarkupTemplate('message_side.tpl'); + DI::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 + '$new' => $new, ]); + $base = DI::baseUrl(); - $end_tpl = get_markup_template('message-end.tpl'); - $a->page['end'] .= replace_macros($end_tpl, [ - '$baseurl' => System::baseUrl(true), - '$base' => $base + $head_tpl = Renderer::getMarkupTemplate('message-head.tpl'); + DI::page()['htmlhead'] .= Renderer::replaceMacros($head_tpl, [ + '$baseurl' => DI::baseUrl()->get(true), + '$base' => $base ]); } function message_post(App $a) { - if (!local_user()) { - notice(L10n::t('Permission denied.') . EOL); + if (!DI::userSession()->getLocalUserId()) { + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); 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']) ? trim($_REQUEST['replyto']) : ''; + $subject = !empty($_REQUEST['subject']) ? trim($_REQUEST['subject']) : ''; + $body = !empty($_REQUEST['body']) ? Strings::escapeHtml(trim($_REQUEST['body'])) : ''; + $recipient = !empty($_REQUEST['recipient']) ? intval($_REQUEST['recipient']) : 0; $ret = Mail::send($recipient, $body, $subject, $replyto); $norecip = false; switch ($ret) { case -1: - notice(L10n::t('No recipient selected.') . EOL); + DI::sysmsg()->addNotice(DI::l10n()->t('No recipient selected.')); $norecip = true; break; + case -2: - notice(L10n::t('Unable to locate contact information.') . EOL); + DI::sysmsg()->addNotice(DI::l10n()->t('Unable to locate contact information.')); break; + case -3: - notice(L10n::t('Message could not be sent.') . EOL); + DI::sysmsg()->addNotice(DI::l10n()->t('Message could not be sent.')); break; + case -4: - notice(L10n::t('Message collection failure.') . EOL); + DI::sysmsg()->addNotice(DI::l10n()->t('Message collection failure.')); break; - default: - 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'; + DI::args()->setArgv(['message', 'new']); } else { - goaway($_SESSION['return_url']); + DI::baseUrl()->redirect(DI::args()->getCommand() . '/' . $ret); } } @@ -100,235 +110,183 @@ function message_content(App $a) $o = ''; Nav::setSelected('messages'); - if (!local_user()) { - notice(L10n::t('Permission denied.') . EOL); - return; + if (!DI::userSession()->getLocalUserId()) { + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); + return Login::form(); } - $myprofile = System::baseUrl() . '/profile/' . $a->user['nickname']; + $myprofile = DI::baseUrl() . '/profile/' . $a->getLoggedInUserNickname(); - $tpl = get_markup_template('mail_head.tpl'); - $header = replace_macros($tpl, [ - '$messages' => L10n::t('Messages'), + $tpl = Renderer::getMarkupTemplate('mail_head.tpl'); + if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'new') { + $button = [ + 'label' => DI::l10n()->t('Discard'), + 'url' => '/message', + 'sel' => 'close', + ]; + } else { + $button = [ + 'label' => DI::l10n()->t('New Message'), + 'url' => '/message/new', + 'sel' => 'new', + 'accesskey' => 'm', + ]; + } + $header = Renderer::replaceMacros($tpl, [ + '$messages' => DI::l10n()->t('Messages'), + '$button' => $button, ]); - if (($a->argc == 3) && ($a->argv[1] === 'drop' || $a->argv[1] === 'dropconv')) { - if (!intval($a->argv[2])) { + if ((DI::args()->getArgc() == 3) && (DI::args()->getArgv()[1] === 'drop' || DI::args()->getArgv()[1] === 'dropconv')) { + if (!intval(DI::args()->getArgv()[2])) { return; } - // Check if we should do HTML-based delete confirmation - if ($_REQUEST['confirm']) { - //