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_CLASSES . 'BxDolEmailTemplates.php' );
|
---|
25 |
|
---|
26 | // --------------- page variables and login
|
---|
27 |
|
---|
28 | $_page['name_index'] = 44;
|
---|
29 | $_page['css_name'] = 'freemail.css';
|
---|
30 |
|
---|
31 | $_page['header'] = _t( "_FREEMAIL_H" );
|
---|
32 |
|
---|
33 | $logged['member'] = member_auth(0, false);
|
---|
34 |
|
---|
35 | // --------------- page components
|
---|
36 |
|
---|
37 | $_ni = $_page['name_index'];
|
---|
38 | $_page_cont[$_ni]['page_main_code'] = DesignBoxContent( $_page['header'], PageCompPageMainCode(), 1);
|
---|
39 | $_page_cont[$_ni]['body_onload'] = '';
|
---|
40 |
|
---|
41 | // --------------- [END] page components
|
---|
42 |
|
---|
43 | PageCode();
|
---|
44 |
|
---|
45 | // --------------- page components functions
|
---|
46 |
|
---|
47 | /**
|
---|
48 | * page code function
|
---|
49 | */
|
---|
50 | function PageCompPageMainCode()
|
---|
51 | {
|
---|
52 | global $_page;
|
---|
53 | $bAjxMod = ($_REQUEST['mode']=='ajax') ? true : false;
|
---|
54 |
|
---|
55 | $member['ID'] = (int)$_COOKIE['memberID'];
|
---|
56 | if (!$_REQUEST['ID'])
|
---|
57 | return _t_err( "_No member specified" );
|
---|
58 |
|
---|
59 | $ID = getID($_REQUEST['ID'], 0);
|
---|
60 | if(!$ID)
|
---|
61 | return _t_err("_PROFILE_NOT_AVAILABLE");
|
---|
62 |
|
---|
63 | $profile = getProfileInfo( $ID );
|
---|
64 |
|
---|
65 | // Check if member can get email ADD CART CHECK HERE
|
---|
66 | $check_res = checkAction( $member['ID'], ACTION_ID_GET_EMAIL );
|
---|
67 | if($check_res[CHECK_ACTION_RESULT] != CHECK_ACTION_RESULT_ALLOWED) {
|
---|
68 | if($bAjxMod)
|
---|
69 | showAjaxModeResult($check_res[CHECK_ACTION_MESSAGE], $ID);
|
---|
70 |
|
---|
71 | return '<div class="soundPop">' . $check_res[CHECK_ACTION_MESSAGE] . '</div>';
|
---|
72 | }
|
---|
73 |
|
---|
74 | // Check if profile found
|
---|
75 |
|
---|
76 | if( !$profile )
|
---|
77 | {
|
---|
78 | $ret = _t_err("_PROFILE_NOT_AVAILABLE");
|
---|
79 | return $ret;
|
---|
80 | }
|
---|
81 |
|
---|
82 | $action_result = "";
|
---|
83 | $get_result = MemberFreeEmail( $member['ID'], $profile );
|
---|
84 |
|
---|
85 | switch ( $get_result )
|
---|
86 | {
|
---|
87 | case 7:
|
---|
88 | $action_result = _t_err( "_PROFILE_NOT_AVAILABLE" );
|
---|
89 | break;
|
---|
90 | case 13:
|
---|
91 | $action_result = _t_err( "_YOUR PROFILE_IS_NOT_ACTIVE" );
|
---|
92 | break;
|
---|
93 | case 20:
|
---|
94 | $action_result = _t_err( "_FREEMAIL_NOT_ALLOWED" );
|
---|
95 | break;
|
---|
96 | case 21:
|
---|
97 | $action_result = _t_err( "_FREEMAIL_ALREADY_SENT", $ID );
|
---|
98 | break;
|
---|
99 | case 25:
|
---|
100 | $action_result = _t_err( "_FREEMAIL_BLOCK", $ID );
|
---|
101 | break;
|
---|
102 | case 44:
|
---|
103 | $action_result = _t_err( "_FREEMAIL_NOT_KISSED", $ID );
|
---|
104 | break;
|
---|
105 | case 45:
|
---|
106 | $action_result = _t_err("_FREEMAIL_ERROR");
|
---|
107 | break;
|
---|
108 | default:
|
---|
109 | $action_result = _t( "_FREEMAIL_SENT", $profile['NickName'] );
|
---|
110 | break;
|
---|
111 | }
|
---|
112 |
|
---|
113 | if ( $get_result )
|
---|
114 | {
|
---|
115 | $_page['header_text'] = _t( "_Contact information not sent" );
|
---|
116 | }
|
---|
117 | else
|
---|
118 | {
|
---|
119 | $_page['header_text'] = _t( "_Contact information sent" );
|
---|
120 | }
|
---|
121 |
|
---|
122 | $ret = '<div class="soundPop">' . $action_result . '</div>' . "\n";
|
---|
123 |
|
---|
124 | if($bAjxMod)
|
---|
125 | showAjaxModeResult($action_result, $ID);
|
---|
126 |
|
---|
127 | return $ret;
|
---|
128 | }
|
---|
129 | function showAjaxModeResult($sMessage, $iId) {
|
---|
130 | $sJQueryJS = genAjaxyPopupJS($iId);
|
---|
131 | echo MsgBox($sMessage) . $sJQueryJS;
|
---|
132 | exit;
|
---|
133 | }
|
---|
134 | function MemberFreeEmail( $recipientID, $profile )
|
---|
135 | {
|
---|
136 | global $site;
|
---|
137 | $anon_mode = getParam('anon_mode');
|
---|
138 |
|
---|
139 | $recipientID = (int)$recipientID;
|
---|
140 | $aRecipientArr = db_arr( "SELECT `Email` FROM `Profiles` WHERE `ID` = '$recipientID' AND `Status` = 'Active'", 0 );
|
---|
141 |
|
---|
142 | if (isBlocked($profile['ID'], $recipientID))
|
---|
143 | {
|
---|
144 | return 25;
|
---|
145 | }
|
---|
146 |
|
---|
147 |
|
---|
148 | if ( !db_arr( "SELECT `ID` FROM `Profiles` WHERE `ID` = '{$profile['ID']}' AND `Status` = 'Active'", 0 ) )
|
---|
149 | {
|
---|
150 | return 7;
|
---|
151 | }
|
---|
152 |
|
---|
153 | if ($anon_mode)
|
---|
154 | {
|
---|
155 | return 20;
|
---|
156 | }
|
---|
157 |
|
---|
158 | $rEmailTemplate = new BxDolEmailTemplates();
|
---|
159 | $aTemplate = $rEmailTemplate -> getTemplate( 't_FreeEmail', $recipientID ) ;
|
---|
160 |
|
---|
161 | if ( $recipientID )
|
---|
162 | {
|
---|
163 | $recipient = $aRecipientArr['Email'];
|
---|
164 | }
|
---|
165 | else
|
---|
166 | {
|
---|
167 | if ( $_GET['Email'] )
|
---|
168 | $recipient = $_GET['Email'];
|
---|
169 | else
|
---|
170 | return 45;
|
---|
171 | }
|
---|
172 |
|
---|
173 | $contact_info = "Email: {$profile['Email']}";
|
---|
174 | if ( strlen( $profile['Phone'] ) )
|
---|
175 | $contact_info .= "\nPhone: {$profile['Phone']}";
|
---|
176 | if ( strlen( $profile['HomeAddress'] ) )
|
---|
177 | $contact_info .= "\nHomeAddress: {$profile['HomeAddress']}";
|
---|
178 | if ( strlen( $profile['HomePage'] ) )
|
---|
179 | $contact_info .= "\nHomePage: {$profile['HomePage']}";
|
---|
180 | if ( strlen( $profile['IcqUIN'] ) )
|
---|
181 | $contact_info .= "\nICQ: {$profile['IcqUIN']}";
|
---|
182 |
|
---|
183 | $aPlus = array();
|
---|
184 | $aPlus['profileContactInfo'] = $contact_info;
|
---|
185 | $aPlus['profileNickName'] = $profile['NickName'];
|
---|
186 | $aPlus['profileID'] = $profile['ID'];
|
---|
187 |
|
---|
188 | $mail_ret = sendMail( $aRecipientArr['Email'], $aTemplate['Subject'], $aTemplate['Body'], $recipientID, $aPlus );
|
---|
189 |
|
---|
190 | if ( $mail_ret )
|
---|
191 | // Perform action
|
---|
192 | checkAction( $memberID, ACTION_ID_GET_EMAIL, true );
|
---|
193 | else
|
---|
194 | return 10;
|
---|
195 |
|
---|
196 | return 0;
|
---|
197 | }
|
---|
198 |
|
---|
199 | ?> |
---|