3 * @file mod/wallmessage.php
6 use Friendica\Core\L10n;
7 use Friendica\Core\Logger;
8 use Friendica\Core\System;
9 use Friendica\Database\DBA;
10 use Friendica\Model\Mail;
11 use Friendica\Model\Profile;
13 function wallmessage_post(App $a) {
15 $replyto = Profile::getMyURL();
17 notice(L10n::t('Permission denied.') . EOL);
21 $subject = ((x($_REQUEST,'subject')) ? notags(trim($_REQUEST['subject'])) : '');
22 $body = ((x($_REQUEST,'body')) ? escape_tags(trim($_REQUEST['body'])) : '');
24 $recipient = (($a->argc > 1) ? notags($a->argv[1]) : '');
25 if ((! $recipient) || (! $body)) {
29 $r = q("select * from user where nickname = '%s' limit 1",
30 DBA::escape($recipient)
33 if (! DBA::isResult($r)) {
34 Logger::log('wallmessage: no recipient');
40 if (! intval($user['unkmail'])) {
41 notice(L10n::t('Permission denied.') . EOL);
45 $r = q("select count(*) as total from mail where uid = %d and created > UTC_TIMESTAMP() - INTERVAL 1 day and unknown = 1",
49 if ($r[0]['total'] > $user['cntunkmail']) {
50 notice(L10n::t('Number of daily wall messages for %s exceeded. Message failed.', $user['username']));
54 $ret = Mail::sendWall($user, $body, $subject, $replyto);
58 notice(L10n::t('No recipient selected.') . EOL);
61 notice(L10n::t('Unable to check your home location.') . EOL);
64 notice(L10n::t('Message could not be sent.') . EOL);
67 notice(L10n::t('Message collection failure.') . EOL);
70 info(L10n::t('Message sent.') . EOL);
73 $a->internalRedirect('profile/'.$user['nickname']);
77 function wallmessage_content(App $a) {
79 if (!Profile::getMyURL()) {
80 notice(L10n::t('Permission denied.') . EOL);
84 $recipient = (($a->argc > 1) ? $a->argv[1] : '');
87 notice(L10n::t('No recipient.') . EOL);
91 $r = q("select * from user where nickname = '%s' limit 1",
92 DBA::escape($recipient)
95 if (! DBA::isResult($r)) {
96 notice(L10n::t('No recipient.') . EOL);
97 Logger::log('wallmessage: no recipient');
103 if (!intval($user['unkmail'])) {
104 notice(L10n::t('Permission denied.') . EOL);
108 $r = q("select count(*) as total from mail where uid = %d and created > UTC_TIMESTAMP() - INTERVAL 1 day and unknown = 1",
112 if ($r[0]['total'] > $user['cntunkmail']) {
113 notice(L10n::t('Number of daily wall messages for %s exceeded. Message failed.', $user['username']));
117 $tpl = get_markup_template('wallmsg-header.tpl');
118 $a->page['htmlhead'] .= replace_macros($tpl, [
119 '$baseurl' => System::baseUrl(true),
120 '$nickname' => $user['nickname'],
121 '$linkurl' => L10n::t('Please enter a link URL:')
124 $tpl = get_markup_template('wallmessage.tpl');
125 $o = replace_macros($tpl, [
126 '$header' => L10n::t('Send Private Message'),
127 '$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']),
128 '$to' => L10n::t('To:'),
129 '$subject' => L10n::t('Subject:'),
130 '$recipname' => $user['username'],
131 '$nickname' => $user['nickname'],
132 '$subjtxt' => ((x($_REQUEST, 'subject')) ? strip_tags($_REQUEST['subject']) : ''),
133 '$text' => ((x($_REQUEST, 'body')) ? escape_tags(htmlspecialchars($_REQUEST['body'])) : ''),
135 '$yourmessage' => L10n::t('Your message:'),
137 '$upload' => L10n::t('Upload photo'),
138 '$insert' => L10n::t('Insert web link'),
139 '$wait' => L10n::t('Please wait')