. * */ use Friendica\App; use Friendica\Content\Nav; use Friendica\Content\Pager; use Friendica\Content\Text\BBCode; use Friendica\Core\ACL; use Friendica\Core\Renderer; use Friendica\Database\DBA; use Friendica\DI; use Friendica\Model\Contact; use Friendica\Model\Mail; use Friendica\Model\Notify\Type; use Friendica\Module\Security\Login; use Friendica\Util\DateTimeFormat; use Friendica\Util\Proxy as ProxyUtils; use Friendica\Util\Strings; use Friendica\Util\Temporal; 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'); } $new = [ 'label' => DI::l10n()->t('New Message'), 'url' => 'message/new', 'sel' => $a->argc > 1 && $a->argv[1] == 'new', 'accesskey' => 'm', ]; $tpl = Renderer::getMarkupTemplate('message_side.tpl'); DI::page()['aside'] = Renderer::replaceMacros($tpl, [ '$tabs' => $tabs, '$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 ]); } function message_post(App $a) { if (!local_user()) { notice(DI::l10n()->t('Permission denied.') . EOL); 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['messageto']) ? intval($_REQUEST['messageto']) : 0; $ret = Mail::send($recipient, $body, $subject, $replyto); $norecip = false; switch ($ret) { case -1: notice(DI::l10n()->t('No recipient selected.') . EOL); $norecip = true; break; case -2: notice(DI::l10n()->t('Unable to locate contact information.') . EOL); break; case -3: notice(DI::l10n()->t('Message could not be sent.') . EOL); break; case -4: notice(DI::l10n()->t('Message collection failure.') . EOL); break; } // fake it to go back to the input form if no recipient listed if ($norecip) { $a->argc = 2; $a->argv[1] = 'new'; } else { DI::baseUrl()->redirect(DI::args()->getCommand() . '/' . $ret); } } function message_content(App $a) { $o = ''; Nav::setSelected('messages'); if (!local_user()) { notice(DI::l10n()->t('Permission denied.') . EOL); return Login::form(); } $myprofile = DI::baseUrl() . '/profile/' . $a->user['nickname']; $tpl = Renderer::getMarkupTemplate('mail_head.tpl'); if ($a->argc > 1 && $a->argv[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])) { return; } // Check if we should do HTML-based delete confirmation if (!empty($_REQUEST['confirm'])) { //