3 * @file mod/wallmessage.php
6 use Friendica\Core\Logger;
7 use Friendica\Core\Renderer;
8 use Friendica\Database\DBA;
10 use Friendica\Model\Mail;
11 use Friendica\Model\Profile;
12 use Friendica\Util\Strings;
14 function wallmessage_post(App $a) {
16 $replyto = Profile::getMyURL();
18 notice(DI::l10n()->t('Permission denied.') . EOL);
22 $subject = (!empty($_REQUEST['subject']) ? Strings::escapeTags(trim($_REQUEST['subject'])) : '');
23 $body = (!empty($_REQUEST['body']) ? Strings::escapeHtml(trim($_REQUEST['body'])) : '');
25 $recipient = (($a->argc > 1) ? Strings::escapeTags($a->argv[1]) : '');
26 if ((! $recipient) || (! $body)) {
30 $r = q("select * from user where nickname = '%s' limit 1",
31 DBA::escape($recipient)
34 if (! DBA::isResult($r)) {
35 Logger::log('wallmessage: no recipient');
41 if (! intval($user['unkmail'])) {
42 notice(DI::l10n()->t('Permission denied.') . EOL);
46 $r = q("select count(*) as total from mail where uid = %d and created > UTC_TIMESTAMP() - INTERVAL 1 day and unknown = 1",
50 if ($r[0]['total'] > $user['cntunkmail']) {
51 notice(DI::l10n()->t('Number of daily wall messages for %s exceeded. Message failed.', $user['username']));
55 $ret = Mail::sendWall($user, $body, $subject, $replyto);
59 notice(DI::l10n()->t('No recipient selected.') . EOL);
62 notice(DI::l10n()->t('Unable to check your home location.') . EOL);
65 notice(DI::l10n()->t('Message could not be sent.') . EOL);
68 notice(DI::l10n()->t('Message collection failure.') . EOL);
71 info(DI::l10n()->t('Message sent.') . EOL);
74 DI::baseUrl()->redirect('profile/'.$user['nickname']);
78 function wallmessage_content(App $a) {
80 if (!Profile::getMyURL()) {
81 notice(DI::l10n()->t('Permission denied.') . EOL);
85 $recipient = (($a->argc > 1) ? $a->argv[1] : '');
88 notice(DI::l10n()->t('No recipient.') . EOL);
92 $r = q("select * from user where nickname = '%s' limit 1",
93 DBA::escape($recipient)
96 if (! DBA::isResult($r)) {
97 notice(DI::l10n()->t('No recipient.') . EOL);
98 Logger::log('wallmessage: no recipient');
104 if (!intval($user['unkmail'])) {
105 notice(DI::l10n()->t('Permission denied.') . EOL);
109 $r = q("select count(*) as total from mail where uid = %d and created > UTC_TIMESTAMP() - INTERVAL 1 day and unknown = 1",
113 if ($r[0]['total'] > $user['cntunkmail']) {
114 notice(DI::l10n()->t('Number of daily wall messages for %s exceeded. Message failed.', $user['username']));
118 $tpl = Renderer::getMarkupTemplate('wallmsg-header.tpl');
119 DI::page()['htmlhead'] .= Renderer::replaceMacros($tpl, [
120 '$baseurl' => DI::baseUrl()->get(true),
121 '$nickname' => $user['nickname'],
122 '$linkurl' => DI::l10n()->t('Please enter a link URL:')
125 $tpl = Renderer::getMarkupTemplate('wallmessage.tpl');
126 $o = Renderer::replaceMacros($tpl, [
127 '$header' => DI::l10n()->t('Send Private Message'),
128 '$subheader' => DI::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']),
129 '$to' => DI::l10n()->t('To:'),
130 '$subject' => DI::l10n()->t('Subject:'),
131 '$recipname' => $user['username'],
132 '$nickname' => $user['nickname'],
133 '$subjtxt' => $_REQUEST['subject'] ?? '',
134 '$text' => $_REQUEST['body'] ?? '',
136 '$yourmessage'=> DI::l10n()->t('Your message:'),
138 '$upload' => DI::l10n()->t('Upload photo'),
139 '$insert' => DI::l10n()->t('Insert web link'),
140 '$wait' => DI::l10n()->t('Please wait')