3 require_once('include/message.php');
5 if(! function_exists('wallmessage_post')) {
6 function wallmessage_post(&$a) {
8 $replyto = get_my_url();
10 notice( t('Permission denied.') . EOL);
14 $subject = ((x($_REQUEST,'subject')) ? notags(trim($_REQUEST['subject'])) : '');
15 $body = ((x($_REQUEST,'body')) ? escape_tags(trim($_REQUEST['body'])) : '');
17 $recipient = (($a->argc > 1) ? notags($a->argv[1]) : '');
18 if((! $recipient) || (! $body)) {
22 $r = q("select * from user where nickname = '%s' limit 1",
27 logger('wallmessage: no recipient');
33 if(! intval($user['unkmail'])) {
34 notice( t('Permission denied.') . EOL);
38 $r = q("select count(*) as total from mail where uid = %d and created > UTC_TIMESTAMP() - INTERVAL 1 day and unknown = 1",
42 if($r[0]['total'] > $user['cntunkmail']) {
43 notice( sprintf( t('Number of daily wall messages for %s exceeded. Message failed.', $user['username'])));
47 // Work around doubled linefeeds in Tinymce 3.5b2
49 $body = str_replace("\r\n","\n",$body);
50 $body = str_replace("\n\n","\n",$body);
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($a->get_baseurl() . '/profile/' . $user['nickname']);
76 if(! function_exists('wallmessage_content')) {
77 function wallmessage_content(&$a) {
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",
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'])));
119 $editselect = 'none';
120 if( feature_enabled(local_user(), 'richtext') )
121 $editselect = '/(profile-jot-text|prvmail-text)/';
123 $tpl = get_markup_template('wallmsg-header.tpl');
124 $a->page['htmlhead'] .= replace_macros($tpl, array(
125 '$baseurl' => $a->get_baseurl(true),
126 '$editselect' => $editselect,
127 '$nickname' => $user['nickname'],
128 '$linkurl' => t('Please enter a link URL:')
131 $tpl = get_markup_template('wallmsg-end.tpl');
132 $a->page['end'] .= replace_macros($tpl, array(
133 '$baseurl' => $a->get_baseurl(true),
134 '$editselect' => $editselect,
135 '$nickname' => $user['nickname'],
136 '$linkurl' => t('Please enter a link URL:')
141 $tpl = get_markup_template('wallmessage.tpl');
142 $o .= replace_macros($tpl,array(
143 '$header' => t('Send Private Message'),
144 '$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']),
146 '$subject' => t('Subject:'),
147 '$recipname' => $user['username'],
148 '$nickname' => $user['nickname'],
149 '$subjtxt' => ((x($_REQUEST,'subject')) ? strip_tags($_REQUEST['subject']) : ''),
150 '$text' => ((x($_REQUEST,'body')) ? escape_tags(htmlspecialchars($_REQUEST['body'])) : ''),
152 '$yourmessage' => t('Your message:'),
153 '$select' => $select,
155 '$upload' => t('Upload photo'),
156 '$insert' => t('Insert web link'),
157 '$wait' => t('Please wait')