]> git.mxchange.org Git - friendica.git/blob - mod/invite.php
Merge branch 'master' of git://github.com/friendika/friendika
[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(  $recip . t(' : ') . t('Not a valid email address.') . EOL);
29                         continue;
30                 }
31
32                 $res = mail($recip, t('Please join my network on ') . $a->config['sitename'], 
33                         $message, "From: " . $a->user['email']);
34                 if($res) {
35                         $total ++;
36                 }
37                 else {
38                         notice( $recip . t(' : ') . t('Message delivery failed.') . EOL);
39                 }
40
41         }
42         notice( $total . t(' messages sent.') . 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' => t('Please join my social network on ') . $a->config['sitename'] . t("\r\n") . t("\r\n")
61                         . t('To accept this invitation, please visit:') . t("\r\n") . t("\r\n") . $a->get_baseurl()
62                         . t("\r\n") . t("\r\n") . t('Once you have registered, please connect with me via my profile page at:') 
63                         . t("\r\n") . t("\r\n") . $a->get_baseurl() . '/profile/' . $a->user['nickname'] ,
64                 '$submit' => t('Submit')
65         ));
66
67         return $o;
68 }