3 * @file mod/wallmessage.php
6 use Friendica\Core\System;
7 use Friendica\Database\DBM;
8 use Friendica\Model\Profile;
10 require_once 'include/message.php';
12 function wallmessage_post(App $a) {
14 $replyto = Profile::getMyURL();
16 notice( 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( 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( sprintf( t('Number of daily wall messages for %s exceeded. Message failed.', $user['username'])));
53 $ret = send_wallmessage($user, $body, $subject, $replyto);
57 notice( t('No recipient selected.') . EOL );
60 notice( t('Unable to check your home location.') . EOL );
63 notice( t('Message could not be sent.') . EOL );
66 notice( t('Message collection failure.') . EOL );
69 info( t('Message sent.') . EOL );
72 goaway('profile/'.$user['nickname']);
77 function wallmessage_content(App $a) {
79 if (!Profile::getMyURL()) {
80 notice(t('Permission denied.') . EOL);
84 $recipient = (($a->argc > 1) ? $a->argv[1] : '');
87 notice( t('No recipient.') . EOL);
91 $r = q("select * from user where nickname = '%s' limit 1",
95 if (! DBM::is_result($r)) {
96 notice( t('No recipient.') . EOL);
97 logger('wallmessage: no recipient');
103 if(! intval($user['unkmail'])) {
104 notice( 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( sprintf( 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, array(
119 '$baseurl' => System::baseUrl(true),
120 '$nickname' => $user['nickname'],
121 '$linkurl' => t('Please enter a link URL:')
124 $tpl = get_markup_template('wallmsg-end.tpl');
125 $a->page['end'] .= replace_macros($tpl, array(
126 '$baseurl' => System::baseUrl(true),
127 '$nickname' => $user['nickname'],
128 '$linkurl' => t('Please enter a link URL:')
131 $tpl = get_markup_template('wallmessage.tpl');
132 $o .= replace_macros($tpl,array(
133 '$header' => t('Send Private Message'),
134 '$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']),
136 '$subject' => t('Subject:'),
137 '$recipname' => $user['username'],
138 '$nickname' => $user['nickname'],
139 '$subjtxt' => ((x($_REQUEST,'subject')) ? strip_tags($_REQUEST['subject']) : ''),
140 '$text' => ((x($_REQUEST,'body')) ? escape_tags(htmlspecialchars($_REQUEST['body'])) : ''),
142 '$yourmessage' => t('Your message:'),
143 '$select' => $select,
145 '$upload' => t('Upload photo'),
146 '$insert' => t('Insert web link'),
147 '$wait' => t('Please wait')