3 * @file mod/wallmessage.php
6 use Friendica\Core\L10n;
7 use Friendica\Core\System;
8 use Friendica\Database\DBM;
9 use Friendica\Model\Mail;
10 use Friendica\Model\Profile;
12 function wallmessage_post(App $a) {
14 $replyto = Profile::getMyURL();
16 notice(L10n::t('Permission denied.') . EOL);
20 $subject = ((x($_REQUEST,'subject')) ? notags(trim($_REQUEST['subject'])) : '');
21 $body = ((x($_REQUEST,'body')) ? escape_tags(trim($_REQUEST['body'])) : '');
23 $recipient = (($a->argc > 1) ? notags($a->argv[1]) : '');
24 if ((! $recipient) || (! $body)) {
28 $r = q("select * from user where nickname = '%s' limit 1",
32 if (! DBM::is_result($r)) {
33 logger('wallmessage: no recipient');
39 if (! intval($user['unkmail'])) {
40 notice(L10n::t('Permission denied.') . EOL);
44 $r = q("select count(*) as total from mail where uid = %d and created > UTC_TIMESTAMP() - INTERVAL 1 day and unknown = 1",
48 if ($r[0]['total'] > $user['cntunkmail']) {
49 notice(L10n::t('Number of daily wall messages for %s exceeded. Message failed.', $user['username']));
53 $ret = Mail::sendWall($user, $body, $subject, $replyto);
57 notice(L10n::t('No recipient selected.') . EOL);
60 notice(L10n::t('Unable to check your home location.') . EOL);
63 notice(L10n::t('Message could not be sent.') . EOL);
66 notice(L10n::t('Message collection failure.') . EOL);
69 info(L10n::t('Message sent.') . EOL);
72 goaway('profile/'.$user['nickname']);
76 function wallmessage_content(App $a) {
78 if (!Profile::getMyURL()) {
79 notice(L10n::t('Permission denied.') . EOL);
83 $recipient = (($a->argc > 1) ? $a->argv[1] : '');
86 notice(L10n::t('No recipient.') . EOL);
90 $r = q("select * from user where nickname = '%s' limit 1",
94 if (! DBM::is_result($r)) {
95 notice(L10n::t('No recipient.') . EOL);
96 logger('wallmessage: no recipient');
102 if (!intval($user['unkmail'])) {
103 notice(L10n::t('Permission denied.') . EOL);
107 $r = q("select count(*) as total from mail where uid = %d and created > UTC_TIMESTAMP() - INTERVAL 1 day and unknown = 1",
111 if ($r[0]['total'] > $user['cntunkmail']) {
112 notice(L10n::t('Number of daily wall messages for %s exceeded. Message failed.', $user['username']));
116 $tpl = get_markup_template('wallmsg-header.tpl');
117 $a->page['htmlhead'] .= replace_macros($tpl, [
118 '$baseurl' => System::baseUrl(true),
119 '$nickname' => $user['nickname'],
120 '$linkurl' => L10n::t('Please enter a link URL:')
123 $tpl = get_markup_template('wallmsg-end.tpl');
124 $a->page['end'] .= replace_macros($tpl, [
125 '$baseurl' => System::baseUrl(true),
126 '$nickname' => $user['nickname'],
127 '$linkurl' => L10n::t('Please enter a link URL:')
130 $tpl = get_markup_template('wallmessage.tpl');
131 $o = replace_macros($tpl, [
132 '$header' => L10n::t('Send Private Message'),
133 '$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']),
134 '$to' => L10n::t('To:'),
135 '$subject' => L10n::t('Subject:'),
136 '$recipname' => $user['username'],
137 '$nickname' => $user['nickname'],
138 '$subjtxt' => ((x($_REQUEST, 'subject')) ? strip_tags($_REQUEST['subject']) : ''),
139 '$text' => ((x($_REQUEST, 'body')) ? escape_tags(htmlspecialchars($_REQUEST['body'])) : ''),
141 '$yourmessage' => L10n::t('Your message:'),
143 '$upload' => L10n::t('Upload photo'),
144 '$insert' => L10n::t('Insert web link'),
145 '$wait' => L10n::t('Please wait')