3 * @file mod/wallmessage.php
6 use Friendica\Core\L10n;
7 use Friendica\Core\Logger;
8 use Friendica\Core\Renderer;
9 use Friendica\Core\System;
10 use Friendica\Database\DBA;
12 use Friendica\Model\Mail;
13 use Friendica\Model\Profile;
14 use Friendica\Util\Strings;
16 function wallmessage_post(App $a) {
18 $replyto = Profile::getMyURL();
20 notice(L10n::t('Permission denied.') . EOL);
24 $subject = (!empty($_REQUEST['subject']) ? Strings::escapeTags(trim($_REQUEST['subject'])) : '');
25 $body = (!empty($_REQUEST['body']) ? Strings::escapeHtml(trim($_REQUEST['body'])) : '');
27 $recipient = (($a->argc > 1) ? Strings::escapeTags($a->argv[1]) : '');
28 if ((! $recipient) || (! $body)) {
32 $r = q("select * from user where nickname = '%s' limit 1",
33 DBA::escape($recipient)
36 if (! DBA::isResult($r)) {
37 Logger::log('wallmessage: no recipient');
43 if (! intval($user['unkmail'])) {
44 notice(L10n::t('Permission denied.') . EOL);
48 $r = q("select count(*) as total from mail where uid = %d and created > UTC_TIMESTAMP() - INTERVAL 1 day and unknown = 1",
52 if ($r[0]['total'] > $user['cntunkmail']) {
53 notice(L10n::t('Number of daily wall messages for %s exceeded. Message failed.', $user['username']));
57 $ret = Mail::sendWall($user, $body, $subject, $replyto);
61 notice(L10n::t('No recipient selected.') . EOL);
64 notice(L10n::t('Unable to check your home location.') . EOL);
67 notice(L10n::t('Message could not be sent.') . EOL);
70 notice(L10n::t('Message collection failure.') . EOL);
73 info(L10n::t('Message sent.') . EOL);
76 DI::baseUrl()->redirect('profile/'.$user['nickname']);
80 function wallmessage_content(App $a) {
82 if (!Profile::getMyURL()) {
83 notice(L10n::t('Permission denied.') . EOL);
87 $recipient = (($a->argc > 1) ? $a->argv[1] : '');
90 notice(L10n::t('No recipient.') . EOL);
94 $r = q("select * from user where nickname = '%s' limit 1",
95 DBA::escape($recipient)
98 if (! DBA::isResult($r)) {
99 notice(L10n::t('No recipient.') . EOL);
100 Logger::log('wallmessage: no recipient');
106 if (!intval($user['unkmail'])) {
107 notice(L10n::t('Permission denied.') . EOL);
111 $r = q("select count(*) as total from mail where uid = %d and created > UTC_TIMESTAMP() - INTERVAL 1 day and unknown = 1",
115 if ($r[0]['total'] > $user['cntunkmail']) {
116 notice(L10n::t('Number of daily wall messages for %s exceeded. Message failed.', $user['username']));
120 $tpl = Renderer::getMarkupTemplate('wallmsg-header.tpl');
121 DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [
122 '$baseurl' => System::baseUrl(true),
123 '$nickname' => $user['nickname'],
124 '$linkurl' => L10n::t('Please enter a link URL:')
127 $tpl = Renderer::getMarkupTemplate('wallmessage.tpl');
128 $o = Renderer::replaceMacros($tpl, [
129 '$header' => L10n::t('Send Private Message'),
130 '$subheader' => L10n::t('If you wish for %s to respond, please check that the privacy settings on your site allow private mail from unknown senders.', $user['username']),
131 '$to' => L10n::t('To:'),
132 '$subject' => L10n::t('Subject:'),
133 '$recipname' => $user['username'],
134 '$nickname' => $user['nickname'],
135 '$subjtxt' => $_REQUEST['subject'] ?? '',
136 '$text' => $_REQUEST['body'] ?? '',
138 '$yourmessage'=> L10n::t('Your message:'),
140 '$upload' => L10n::t('Upload photo'),
141 '$insert' => L10n::t('Insert web link'),
142 '$wait' => L10n::t('Please wait')