]> git.mxchange.org Git - friendica.git/blob - mod/invite.php
update source strings
[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, "From: " . $a->user['email']);
34                 if($res) {
35                         $total ++;
36                 }
37                 else {
38                         notice( sprintf( t('%s : Message delivery failed.'), $recip) . EOL);
39                 }
40
41         }
42         notice( sprintf(tt("%d message sent.", "%d messages sent.", $total), $total) . EOL);
43         return;
44 }
45
46
47 function invite_content(&$a) {
48
49         if(! local_user()) {
50                 notice( t('Permission denied.') . EOL);
51                 return;
52         }
53
54         $tpl = load_view_file('view/invite.tpl');
55         
56         $o = replace_macros($tpl, array(
57                 '$invite' => t('Send invitations'),
58                 '$addr_text' => t('Enter email addresses, one per line:'),
59                 '$msg_text' => t('Your message:'),
60                 '$default_message' => sprintf(t('Please join my social network on %s'), $a->config['sitename']) . "\r\n" . "\r\n"
61                         . t('To accept this invitation, please visit:') . "\r\n" . "\r\n" . $a->get_baseurl()
62                         . "\r\n" . "\r\n" . t('Once you have registered, please connect with me via my profile page at:') 
63                         . "\r\n" . "\r\n" . $a->get_baseurl() . '/profile/' . $a->user['nickname'] ,
64                 '$submit' => t('Submit')
65         ));
66
67         return $o;
68 }