]> git.mxchange.org Git - friendica.git/blob - mod/invite.php
deprecate load_view_file
[friendica.git] / mod / invite.php
1 <?php
2
3 /**
4  * module: invite.php
5  *
6  * send email invitations to join social network
7  *
8  */
9
10 function invite_post(&$a) {
11
12         if(! local_user()) {
13                 notice( t('Permission denied.') . EOL);
14                 return;
15         }
16
17
18         $recips  = ((x($_POST,'recipients')) ? explode("\n",$_POST['recipients']) : array());
19         $message = ((x($_POST,'message'))    ? notags(trim($_POST['message']))    : '');
20
21         $total = 0;
22
23         foreach($recips as $recip) {
24
25                 $recip = trim($recip);
26
27                 if(! valid_email($recip)) {
28                         notice(  sprintf( t('%s : Not a valid email address.'), $recip) . EOL);
29                         continue;
30                 }
31
32                 $res = mail($recip, sprintf(t('Please join my network on %s'), $a->config['sitename']), 
33                         $message, 
34                         "From: " . $a->user['email'] . "\n"
35                         . 'Content-type: text/plain; charset=UTF-8' . "\n"
36                         . 'Content-transfer-encoding: 8bit' );
37
38                 if($res) {
39                         $total ++;
40                 }
41                 else {
42                         notice( sprintf( t('%s : Message delivery failed.'), $recip) . EOL);
43                 }
44
45         }
46         notice( sprintf( tt("%d message sent.", "%d messages sent.", $total) , $total) . EOL);
47         return;
48 }
49
50
51 function invite_content(&$a) {
52
53         if(! local_user()) {
54                 notice( t('Permission denied.') . EOL);
55                 return;
56         }
57
58         $tpl = get_markup_template('invite.tpl');
59         
60         $o = replace_macros($tpl, array(
61                 '$invite' => t('Send invitations'),
62                 '$addr_text' => t('Enter email addresses, one per line:'),
63                 '$msg_text' => t('Your message:'),
64                 '$default_message' => sprintf(t('Please join my social network on %s'), $a->config['sitename']) . "\r\n" . "\r\n"
65                         . t('To accept this invitation, please visit:') . "\r\n" . "\r\n" . $a->get_baseurl()
66                         . "\r\n" . "\r\n" . t('Once you have registered, please connect with me via my profile page at:') 
67                         . "\r\n" . "\r\n" . $a->get_baseurl() . '/profile/' . $a->user['nickname'] ,
68                 '$submit' => t('Submit')
69         ));
70
71         return $o;
72 }