]> git.mxchange.org Git - friendica.git/blob - mod/invite.php
mistpark 2.0 infrasturcture lands
[friendica.git] / mod / invite.php
1 <?php
2
3
4 function invite_post(&$a) {
5         if(! local_user()) {
6                 notice( t('Permission denied.') . EOL);
7                 return;
8         }
9
10
11         $recips = explode("\n",$_POST['recipients']);
12         $message = $_POST['message'];
13
14         $total = 0;
15
16         foreach($recips as $recip) {
17
18                 $recip = trim($recip);
19
20                 if(!eregi('[A-Za-z0-9._%-]+@[A-Za-z0-9._%-]+\.[A-Za-z]{2,6}', $recip)) {
21                         notice(  $recip . t(' : ') . t('Not a valid email address.') . EOL);
22                         continue;
23                 }
24
25                 $res = mail($recip, t('Please join my network on ') . $a->config['sitename'], $message, "From: " . $a->user['email']);
26                 if($res) {
27                         $total ++;
28                 }
29                 else {
30                         notice( $recip . t(' : ') . t('Message delivery failed.') . EOL);
31                 }
32
33         }
34         notice( $total . t(' messages sent.') . EOL);
35         return;
36 }
37
38
39 function invite_content(&$a) {
40         if(! local_user()) {
41                 notice( t('Permission denied.') . EOL);
42                 return;
43         }
44
45         $tpl = file_get_contents('view/invite.tpl');
46         
47         $o = replace_macros($tpl, array(
48                 '$invite' => t('Send invitations'),
49                 '$addr_text' => t('Enter email addresses, one per line:'),
50                 '$msg_text' => t('Your message:'),
51                 '$default_message' => t('Please join my social network on ') . $a->config['sitename'] . t("\r\n") . t("\r\n")
52                         . t('To accept this invitation, please visit:') . t("\r\n") . t("\r\n") . $a->get_baseurl()
53                         . t("\r\n") . t("\r\n") . t('Once you have registered, please make an introduction via my profile page at:') 
54                         . t("\r\n") . t("\r\n") . $a->get_baseurl() . '/profile/' . $a->user['nickname'] ,
55                 '$submit' => t('Submit')
56         ));
57
58         return $o;
59 }