1 | <?php
|
---|
2 |
|
---|
3 | /***************************************************************************
|
---|
4 | * Dolphin Smart Community Builder
|
---|
5 | * -----------------
|
---|
6 | * begin : Mon Mar 23 2006
|
---|
7 | * copyright : (C) 2006 BoonEx Group
|
---|
8 | * website : http://www.boonex.com/
|
---|
9 | * This file is part of Dolphin - Smart Community Builder
|
---|
10 | *
|
---|
11 | * Dolphin is free software. This work is licensed under a Creative Commons Attribution 3.0 License.
|
---|
12 | * http://creativecommons.org/licenses/by/3.0/
|
---|
13 | *
|
---|
14 | * Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
---|
15 | * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
---|
16 | * See the Creative Commons Attribution 3.0 License for more details.
|
---|
17 | * You should have received a copy of the Creative Commons Attribution 3.0 License along with Dolphin,
|
---|
18 | * see license.txt file; if not, write to marketing@boonex.com
|
---|
19 | ***************************************************************************/
|
---|
20 |
|
---|
21 | require_once('inc/header.inc.php');
|
---|
22 | require_once(BX_DIRECTORY_PATH_INC . 'design.inc.php');
|
---|
23 | require_once(BX_DIRECTORY_PATH_INC . 'profiles.inc.php');
|
---|
24 | require_once(BX_DIRECTORY_PATH_INC . 'utils.inc.php');
|
---|
25 | require_once(BX_DIRECTORY_PATH_CLASSES . 'BxDolEmailTemplates.php');
|
---|
26 |
|
---|
27 | bx_import('BxTemplFormView');
|
---|
28 |
|
---|
29 | // --------------- page variables and login
|
---|
30 |
|
---|
31 | $_page['name_index'] = 29;
|
---|
32 | $_page['css_name'] = array('general.css', 'tellfriend.css', 'forms_adv.css');
|
---|
33 |
|
---|
34 | $logged['member'] = member_auth( 0, false );
|
---|
35 |
|
---|
36 | $_page['header'] = _t("_Tell a friend");
|
---|
37 | $_page['header_text'] = _t("_Tell a friend");
|
---|
38 |
|
---|
39 | $profileID = 0;
|
---|
40 | if( isset($_GET['ID']) ) {
|
---|
41 | $profileID = (int) $_GET['ID'];
|
---|
42 | }
|
---|
43 | else if( isset($_POST['ID']) ) {
|
---|
44 | $profileID = (int) $_POST['ID'];
|
---|
45 | }
|
---|
46 |
|
---|
47 | if($profileID > 0) {
|
---|
48 | $iVisitorID = (isMember() || isAdmin()) ? (int)$_COOKIE['memberID'] : 0;
|
---|
49 |
|
---|
50 | if($iVisitorID > 0) {
|
---|
51 | $aVisitorInfo = getProfileInfo($iVisitorID);
|
---|
52 | $sVisitorName = $aVisitorInfo['NickName'];
|
---|
53 | $sVisitorEmail = $aVisitorInfo['Email'];
|
---|
54 | }
|
---|
55 | }
|
---|
56 |
|
---|
57 | // --------------- GET/POST actions
|
---|
58 | $tell_friend_text = '';
|
---|
59 | if($_POST['submit_send']) {
|
---|
60 | $tell_friend_text = SendTellFriend() ? MsgBox(_t("_Email was successfully sent")) : MsgBox(_t("_Email sent failed"));
|
---|
61 | }
|
---|
62 |
|
---|
63 | // --------------- page components
|
---|
64 | $sYEmlNotValidC = _t('_Incorrect Email');
|
---|
65 | $sFEmlNotValidC = $sYEmlNotValidC . ' (' . _t('_Friend email') . ')';
|
---|
66 |
|
---|
67 | $sCaption = ($profileID) ? _t('_TELLAFRIEND2', $site['title']) : _t('_TELLAFRIEND', $site['title']);
|
---|
68 |
|
---|
69 | $aForm = array(
|
---|
70 | 'form_attrs' => array(
|
---|
71 | 'id' => 'invite_friend',
|
---|
72 | 'name' => 'invite_friend',
|
---|
73 | 'action' => $_SERVER['PHP_SELF'],
|
---|
74 | 'method' => 'post',
|
---|
75 | 'enctype' => 'multipart/form-data',
|
---|
76 | 'onsubmit' => "var feml = document.forms['invite_friend'].friends_emails; var yeml = document.forms['invite_friend'].email; var bRet = true; if(emailCheck(yeml.value)==false) { alert('{$sYEmlNotValidC}'); bRet = false; } if (emailCheck(feml.value)==false) { alert('{$sFEmlNotValidC}'); bRet = false; } return bRet; "
|
---|
77 | ),
|
---|
78 | 'inputs' => array (
|
---|
79 | 'header1' => array(
|
---|
80 | 'type' => 'block_header',
|
---|
81 | 'caption' => $sCaption,
|
---|
82 | ),
|
---|
83 | 'id' => array(
|
---|
84 | 'type' => 'hidden',
|
---|
85 | 'name' => 'ID',
|
---|
86 | 'value' => $profileID
|
---|
87 | ),
|
---|
88 | 'name' => array(
|
---|
89 | 'type' => 'text',
|
---|
90 | 'name' => 'name',
|
---|
91 | 'caption' => _t("_Your name"),
|
---|
92 | 'value' => $sVisitorName
|
---|
93 | ),
|
---|
94 | 'email' => array(
|
---|
95 | 'type' => 'text',
|
---|
96 | 'name' => 'email',
|
---|
97 | 'caption' => _t("_Your email"),
|
---|
98 | 'value' => $sVisitorEmail
|
---|
99 | ),
|
---|
100 | 'friends_emails' => array(
|
---|
101 | 'type' => 'text',
|
---|
102 | 'name' => 'friends_emails',
|
---|
103 | 'caption' => _t("_Friend email"),
|
---|
104 | 'value' => ''
|
---|
105 | ),
|
---|
106 | 'submit_send' => array(
|
---|
107 | 'type' => 'submit',
|
---|
108 | 'name' => 'submit_send',
|
---|
109 | 'value' => _t("_Send Letter"),
|
---|
110 | ),
|
---|
111 | )
|
---|
112 | );
|
---|
113 |
|
---|
114 | $oForm = new BxTemplFormView($aForm);
|
---|
115 |
|
---|
116 | $_ni = $_page['name_index'];
|
---|
117 | $_page_cont[$_ni]['page_code'] = $tell_friend_text . $oForm->getCode();
|
---|
118 | // --------------- [END] page components
|
---|
119 |
|
---|
120 | PageCode();
|
---|
121 | // --------------- page components functions
|
---|
122 |
|
---|
123 | /**
|
---|
124 | * send "tell a friend" email
|
---|
125 | */
|
---|
126 |
|
---|
127 | function SendTellFriend() {
|
---|
128 | global $profileID;
|
---|
129 |
|
---|
130 | $iVisitorID = (isMember() || isAdmin()) ? (int)$_COOKIE['memberID'] : 0;
|
---|
131 |
|
---|
132 | if ( strlen( trim($_POST['friends_emails']) ) <= 0 )
|
---|
133 | return 0;
|
---|
134 | if ( strlen( trim($_POST['email']) ) <= 0 )
|
---|
135 | return 0;
|
---|
136 |
|
---|
137 | $rEmailTemplate = new BxDolEmailTemplates();
|
---|
138 | if ( $profileID )
|
---|
139 | {
|
---|
140 | $aTemplate = $rEmailTemplate -> getTemplate( 't_TellFriendProfile', $profileID ) ;
|
---|
141 | }
|
---|
142 | else
|
---|
143 | {
|
---|
144 | $aTemplate = $rEmailTemplate -> getTemplate( 't_TellFriend' ) ;
|
---|
145 | }
|
---|
146 |
|
---|
147 | $recipient = $_POST['friends_emails'];
|
---|
148 |
|
---|
149 | $headers .= "From: =?UTF-8?B?" . base64_encode( $_POST['name'] ) . "?= <{$_POST['email']}>";
|
---|
150 | $headers = "MIME-Version: 1.0\r\n" . "Content-type: text/html; charset=UTF-8\r\n" . $headers;
|
---|
151 | $headers2 .= "-f{$_POST['email']}";
|
---|
152 |
|
---|
153 | $sLinkAdd = ($iVisitorID) ? 'idFriend='. $iVisitorID : '';
|
---|
154 |
|
---|
155 | if ( $profileID )
|
---|
156 | $Link = getProfileLink($profileID, $sLinkAdd);
|
---|
157 | else
|
---|
158 | $Link = BX_DOL_URL_ROOT . ( $sLinkAdd ? "?{$sLinkAdd}" : '' );
|
---|
159 |
|
---|
160 | $message = $aTemplate['Body'];
|
---|
161 | $message = str_replace( "<Link>", $Link, $message );
|
---|
162 | $message = str_replace( "<FromName>", $_POST['name'], $message );
|
---|
163 |
|
---|
164 | return mail( $recipient, $aTemplate['Subject'], $message, $headers, $headers2 );
|
---|
165 | }
|
---|
166 |
|
---|
167 | ?> |
---|