5 require_once('include/message.php');
7 function wallmessage_post(App $a) {
9 $replyto = get_my_url();
11 notice( t('Permission denied.') . EOL);
15 $subject = ((x($_REQUEST,'subject')) ? notags(trim($_REQUEST['subject'])) : '');
16 $body = ((x($_REQUEST,'body')) ? escape_tags(trim($_REQUEST['body'])) : '');
18 $recipient = (($a->argc > 1) ? notags($a->argv[1]) : '');
19 if((! $recipient) || (! $body)) {
23 $r = q("select * from user where nickname = '%s' limit 1",
27 if (! dbm::is_result($r)) {
28 logger('wallmessage: no recipient');
34 if(! intval($user['unkmail'])) {
35 notice( t('Permission denied.') . EOL);
39 $r = q("select count(*) as total from mail where uid = %d and created > UTC_TIMESTAMP() - INTERVAL 1 day and unknown = 1",
43 if($r[0]['total'] > $user['cntunkmail']) {
44 notice( sprintf( t('Number of daily wall messages for %s exceeded. Message failed.', $user['username'])));
48 $ret = send_wallmessage($user, $body, $subject, $replyto);
52 notice( t('No recipient selected.') . EOL );
55 notice( t('Unable to check your home location.') . EOL );
58 notice( t('Message could not be sent.') . EOL );
61 notice( t('Message collection failure.') . EOL );
64 info( t('Message sent.') . EOL );
67 goaway('profile/'.$user['nickname']);
72 function wallmessage_content(App $a) {
75 notice( t('Permission denied.') . EOL);
79 $recipient = (($a->argc > 1) ? $a->argv[1] : '');
82 notice( t('No recipient.') . EOL);
86 $r = q("select * from user where nickname = '%s' limit 1",
90 if (! dbm::is_result($r)) {
91 notice( t('No recipient.') . EOL);
92 logger('wallmessage: no recipient');
98 if(! intval($user['unkmail'])) {
99 notice( t('Permission denied.') . EOL);
103 $r = q("select count(*) as total from mail where uid = %d and created > UTC_TIMESTAMP() - INTERVAL 1 day and unknown = 1",
107 if($r[0]['total'] > $user['cntunkmail']) {
108 notice( sprintf( t('Number of daily wall messages for %s exceeded. Message failed.', $user['username'])));
112 $tpl = get_markup_template('wallmsg-header.tpl');
113 $a->page['htmlhead'] .= replace_macros($tpl, array(
114 '$baseurl' => $a->get_baseurl(true),
115 '$nickname' => $user['nickname'],
116 '$linkurl' => t('Please enter a link URL:')
119 $tpl = get_markup_template('wallmsg-end.tpl');
120 $a->page['end'] .= replace_macros($tpl, array(
121 '$baseurl' => $a->get_baseurl(true),
122 '$nickname' => $user['nickname'],
123 '$linkurl' => t('Please enter a link URL:')
126 $tpl = get_markup_template('wallmessage.tpl');
127 $o .= replace_macros($tpl,array(
128 '$header' => t('Send Private Message'),
129 '$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']),
131 '$subject' => t('Subject:'),
132 '$recipname' => $user['username'],
133 '$nickname' => $user['nickname'],
134 '$subjtxt' => ((x($_REQUEST,'subject')) ? strip_tags($_REQUEST['subject']) : ''),
135 '$text' => ((x($_REQUEST,'body')) ? escape_tags(htmlspecialchars($_REQUEST['body'])) : ''),
137 '$yourmessage' => t('Your message:'),
138 '$select' => $select,
140 '$upload' => t('Upload photo'),
141 '$insert' => t('Insert web link'),
142 '$wait' => t('Please wait')