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;
11 use Friendica\Model\Mail;
12 use Friendica\Model\Profile;
13 use Friendica\Util\Strings;
15 function wallmessage_post(App $a) {
17 $replyto = Profile::getMyURL();
19 notice(L10n::t('Permission denied.') . EOL);
23 $subject = (!empty($_REQUEST['subject']) ? Strings::escapeTags(trim($_REQUEST['subject'])) : '');
24 $body = (!empty($_REQUEST['body']) ? Strings::escapeHtml(trim($_REQUEST['body'])) : '');
26 $recipient = (($a->argc > 1) ? Strings::escapeTags($a->argv[1]) : '');
27 if ((! $recipient) || (! $body)) {
31 $r = q("select * from user where nickname = '%s' limit 1",
32 DBA::escape($recipient)
35 if (! DBA::isResult($r)) {
36 Logger::log('wallmessage: no recipient');
42 if (! intval($user['unkmail'])) {
43 notice(L10n::t('Permission denied.') . EOL);
47 $r = q("select count(*) as total from mail where uid = %d and created > UTC_TIMESTAMP() - INTERVAL 1 day and unknown = 1",
51 if ($r[0]['total'] > $user['cntunkmail']) {
52 notice(L10n::t('Number of daily wall messages for %s exceeded. Message failed.', $user['username']));
56 $ret = Mail::sendWall($user, $body, $subject, $replyto);
60 notice(L10n::t('No recipient selected.') . EOL);
63 notice(L10n::t('Unable to check your home location.') . EOL);
66 notice(L10n::t('Message could not be sent.') . EOL);
69 notice(L10n::t('Message collection failure.') . EOL);
72 info(L10n::t('Message sent.') . EOL);
75 $a->internalRedirect('profile/'.$user['nickname']);
79 function wallmessage_content(App $a) {
81 if (!Profile::getMyURL()) {
82 notice(L10n::t('Permission denied.') . EOL);
86 $recipient = (($a->argc > 1) ? $a->argv[1] : '');
89 notice(L10n::t('No recipient.') . EOL);
93 $r = q("select * from user where nickname = '%s' limit 1",
94 DBA::escape($recipient)
97 if (! DBA::isResult($r)) {
98 notice(L10n::t('No recipient.') . EOL);
99 Logger::log('wallmessage: no recipient');
105 if (!intval($user['unkmail'])) {
106 notice(L10n::t('Permission denied.') . EOL);
110 $r = q("select count(*) as total from mail where uid = %d and created > UTC_TIMESTAMP() - INTERVAL 1 day and unknown = 1",
114 if ($r[0]['total'] > $user['cntunkmail']) {
115 notice(L10n::t('Number of daily wall messages for %s exceeded. Message failed.', $user['username']));
119 $tpl = Renderer::getMarkupTemplate('wallmsg-header.tpl');
120 $a->page['htmlhead'] .= Renderer::replaceMacros($tpl, [
121 '$baseurl' => System::baseUrl(true),
122 '$nickname' => $user['nickname'],
123 '$linkurl' => L10n::t('Please enter a link URL:')
126 $tpl = Renderer::getMarkupTemplate('wallmessage.tpl');
127 $o = Renderer::replaceMacros($tpl, [
128 '$header' => L10n::t('Send Private Message'),
129 '$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']),
130 '$to' => L10n::t('To:'),
131 '$subject' => L10n::t('Subject:'),
132 '$recipname' => $user['username'],
133 '$nickname' => $user['nickname'],
134 '$subjtxt' => defaults($_REQUEST, 'subject', ''),
135 '$text' => defaults($_REQUEST, 'body', ''),
137 '$yourmessage'=> L10n::t('Your message:'),
139 '$upload' => L10n::t('Upload photo'),
140 '$insert' => L10n::t('Insert web link'),
141 '$wait' => L10n::t('Please wait')