X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=mod%2Fmessage.php;h=794d2ace43e428806950581906e2060300c04fc4;hb=316d50cf7aad7f2db21fab988ea5abaddf667750;hp=6326bb9ea5ffb282e4b3b85645d9e8e89492f5a3;hpb=fb7f7435c080e15bdafbbcbb5a3dfd94ef8dd952;p=friendica.git diff --git a/mod/message.php b/mod/message.php index 6326bb9ea5..794d2ace43 100644 --- a/mod/message.php +++ b/mod/message.php @@ -1,6 +1,6 @@ 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' => DI::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 = Renderer::getMarkupTemplate('message_side.tpl'); DI::page()['aside'] = Renderer::replaceMacros($tpl, [ '$tabs' => $tabs, - '$new' => $new, + '$new' => $new, ]); $base = DI::baseUrl(); $head_tpl = Renderer::getMarkupTemplate('message-head.tpl'); DI::page()['htmlhead'] .= Renderer::replaceMacros($head_tpl, [ '$baseurl' => DI::baseUrl()->get(true), - '$base' => $base + '$base' => $base ]); } function message_post(App $a) { - if (!local_user()) { - notice(DI::l10n()->t('Permission denied.')); + if (!DI::userSession()->getLocalUserId()) { + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); return; } - $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['recipient']) ? intval($_REQUEST['recipient']) : 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(DI::l10n()->t('No recipient selected.')); + DI::sysmsg()->addNotice(DI::l10n()->t('No recipient selected.')); $norecip = true; break; + case -2: - notice(DI::l10n()->t('Unable to locate contact information.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Unable to locate contact information.')); break; + case -3: - notice(DI::l10n()->t('Message could not be sent.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Message could not be sent.')); break; + case -4: - notice(DI::l10n()->t('Message collection failure.')); + DI::sysmsg()->addNotice(DI::l10n()->t('Message collection failure.')); break; } // 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 { DI::baseUrl()->redirect(DI::args()->getCommand() . '/' . $ret); } @@ -109,131 +110,98 @@ function message_content(App $a) $o = ''; Nav::setSelected('messages'); - if (!local_user()) { - notice(DI::l10n()->t('Permission denied.')); + if (!DI::userSession()->getLocalUserId()) { + DI::sysmsg()->addNotice(DI::l10n()->t('Permission denied.')); return Login::form(); } - $myprofile = DI::baseUrl() . '/profile/' . $a->user['nickname']; + $myprofile = DI::baseUrl() . '/profile/' . $a->getLoggedInUserNickname(); $tpl = Renderer::getMarkupTemplate('mail_head.tpl'); - if ($a->argc > 1 && $a->argv[1] == 'new') { + if (DI::args()->getArgc() > 1 && DI::args()->getArgv()[1] == 'new') { $button = [ 'label' => DI::l10n()->t('Discard'), - 'url' => '/message', - 'sel' => 'close', + 'url' => '/message', + 'sel' => 'close', ]; } else { $button = [ - 'label' => DI::l10n()->t('New Message'), - 'url' => '/message/new', - 'sel' => 'new', + 'label' => DI::l10n()->t('New Message'), + 'url' => '/message/new', + 'sel' => 'new', 'accesskey' => 'm', ]; } $header = Renderer::replaceMacros($tpl, [ '$messages' => DI::l10n()->t('Messages'), - '$button' => $button, + '$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 (!empty($_REQUEST['confirm'])) { - //