4 use \Friendica\Core\System;
5 use Friendica\Database\DBM;
7 require_once('include/message.php');
9 function wallmessage_post(App $a) {
11 $replyto = get_my_url();
13 notice( t('Permission denied.') . EOL);
17 $subject = ((x($_REQUEST,'subject')) ? notags(trim($_REQUEST['subject'])) : '');
18 $body = ((x($_REQUEST,'body')) ? escape_tags(trim($_REQUEST['body'])) : '');
20 $recipient = (($a->argc > 1) ? notags($a->argv[1]) : '');
21 if((! $recipient) || (! $body)) {
25 $r = q("select * from user where nickname = '%s' limit 1",
29 if (! DBM::is_result($r)) {
30 logger('wallmessage: no recipient');
36 if(! intval($user['unkmail'])) {
37 notice( t('Permission denied.') . EOL);
41 $r = q("select count(*) as total from mail where uid = %d and created > UTC_TIMESTAMP() - INTERVAL 1 day and unknown = 1",
45 if($r[0]['total'] > $user['cntunkmail']) {
46 notice( sprintf( t('Number of daily wall messages for %s exceeded. Message failed.', $user['username'])));
50 $ret = send_wallmessage($user, $body, $subject, $replyto);
54 notice( t('No recipient selected.') . EOL );
57 notice( t('Unable to check your home location.') . EOL );
60 notice( t('Message could not be sent.') . EOL );
63 notice( t('Message collection failure.') . EOL );
66 info( t('Message sent.') . EOL );
69 goaway('profile/'.$user['nickname']);
74 function wallmessage_content(App $a) {
77 notice( t('Permission denied.') . EOL);
81 $recipient = (($a->argc > 1) ? $a->argv[1] : '');
84 notice( t('No recipient.') . EOL);
88 $r = q("select * from user where nickname = '%s' limit 1",
92 if (! DBM::is_result($r)) {
93 notice( t('No recipient.') . EOL);
94 logger('wallmessage: no recipient');
100 if(! intval($user['unkmail'])) {
101 notice( t('Permission denied.') . EOL);
105 $r = q("select count(*) as total from mail where uid = %d and created > UTC_TIMESTAMP() - INTERVAL 1 day and unknown = 1",
109 if($r[0]['total'] > $user['cntunkmail']) {
110 notice( sprintf( t('Number of daily wall messages for %s exceeded. Message failed.', $user['username'])));
114 $tpl = get_markup_template('wallmsg-header.tpl');
115 $a->page['htmlhead'] .= replace_macros($tpl, array(
116 '$baseurl' => System::baseUrl(true),
117 '$nickname' => $user['nickname'],
118 '$linkurl' => t('Please enter a link URL:')
121 $tpl = get_markup_template('wallmsg-end.tpl');
122 $a->page['end'] .= replace_macros($tpl, array(
123 '$baseurl' => System::baseUrl(true),
124 '$nickname' => $user['nickname'],
125 '$linkurl' => t('Please enter a link URL:')
128 $tpl = get_markup_template('wallmessage.tpl');
129 $o .= replace_macros($tpl,array(
130 '$header' => t('Send Private Message'),
131 '$subheader' => sprintf( 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']),
133 '$subject' => t('Subject:'),
134 '$recipname' => $user['username'],
135 '$nickname' => $user['nickname'],
136 '$subjtxt' => ((x($_REQUEST,'subject')) ? strip_tags($_REQUEST['subject']) : ''),
137 '$text' => ((x($_REQUEST,'body')) ? escape_tags(htmlspecialchars($_REQUEST['body'])) : ''),
139 '$yourmessage' => t('Your message:'),
140 '$select' => $select,
142 '$upload' => t('Upload photo'),
143 '$insert' => t('Insert web link'),
144 '$wait' => t('Please wait')