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 | define('BX_SECURITY_EXCEPTIONS', true);
|
---|
22 | $aBxSecurityExceptions = array(
|
---|
23 | 'POST.body',
|
---|
24 | 'REQUEST.body',
|
---|
25 | );
|
---|
26 |
|
---|
27 | require_once( '../inc/header.inc.php' );
|
---|
28 | require_once( BX_DIRECTORY_PATH_INC . 'design.inc.php' );
|
---|
29 | require_once( BX_DIRECTORY_PATH_INC . 'admin_design.inc.php' );
|
---|
30 | require_once( BX_DIRECTORY_PATH_INC . 'utils.inc.php' );
|
---|
31 | require_once( BX_DIRECTORY_PATH_INC . 'prof.inc.php' );
|
---|
32 |
|
---|
33 | bx_import('BxTemplFormView');
|
---|
34 | bx_import('BxDolEmailTemplates');
|
---|
35 |
|
---|
36 | $logged['admin'] = member_auth(1, true, true);
|
---|
37 |
|
---|
38 | if($_REQUEST['queue_message'] && $_REQUEST['msgs_id'])
|
---|
39 | $sActionResult = QueueMessage();
|
---|
40 | if ($_REQUEST['add_message'])
|
---|
41 | $action = 'add';
|
---|
42 | if($_REQUEST['delete_message'] && $_REQUEST['msgs_id'])
|
---|
43 | $sActionResult = DeleteMessage() ? _t('_adm_mmail_Message_was_deleted') : _t('_adm_mmail_Message_was_not_deleted');
|
---|
44 | if($_REQUEST['preview_message'] && $_REQUEST['msgs_id'])
|
---|
45 | $action = 'preview';
|
---|
46 | if($_REQUEST['action'] == 'empty' )
|
---|
47 | $sActionResult = EmptyQueue() ? _t('_adm_mmail_Queue_empty') : _t('_adm_mmail_Queue_emptying_failed');
|
---|
48 |
|
---|
49 | $iNameIndex = 13;
|
---|
50 | $_page = array(
|
---|
51 | 'name_index' => $iNameIndex,
|
---|
52 | 'css_name' => array('forms_adv.css'),
|
---|
53 | 'header' => _t('_adm_mmail_title')
|
---|
54 | );
|
---|
55 |
|
---|
56 | $_page_cont[$iNameIndex] = array(
|
---|
57 | 'page_code_status' => PrintStatus($sActionResult),
|
---|
58 | 'page_code_new_message' => getEmailMessage($action),
|
---|
59 | 'page_code_preview_message' => $action == 'preview' && strlen($_REQUEST['body']) ? PreviewMessage() : '',
|
---|
60 | 'page_code_all_messages' => getAllMessagesBox(),
|
---|
61 | 'page_code_queue_message' => getQueueMessage()
|
---|
62 | );
|
---|
63 |
|
---|
64 | PageCodeAdmin();
|
---|
65 |
|
---|
66 | function PrintStatus($sActionResult) {
|
---|
67 | $sSubjC = _t('_Subject');
|
---|
68 | $sEmailsC = _t('_adm_mmail_emails');
|
---|
69 | $sEmptyQueueC = _t('_adm_mmail_Empty_Queue');
|
---|
70 | $sCupidStatusC = _t('_adm_mmail_Cupid_mails_status');
|
---|
71 |
|
---|
72 | $sSingleEmailsTRs = '';
|
---|
73 |
|
---|
74 | // Select count of emails in queue per one message
|
---|
75 | $iCount = (int)$GLOBALS['MySQL']->getOne("SELECT COUNT(`id`) AS `count` FROM `sys_sbs_queue`");
|
---|
76 | if ($iCount <= 0)
|
---|
77 | $sSingleEmailsTRs .= "<tr><td align=center><b><font color=red>" . _t('_adm_mmail_no_emails_in_queue') . "</font></b></td></tr>";
|
---|
78 | else
|
---|
79 | $sSingleEmailsTRs .= "<tr><td align=center>" . _t('_adm_mmail_mails_in_queue', $iCount) . "</td></tr>";
|
---|
80 |
|
---|
81 | $sEmptyQueueTable = '';
|
---|
82 | // If queue is not empty then show link to clear it
|
---|
83 | if($iCount > 0) {
|
---|
84 | $sEmptyQueueTable = "<hr>
|
---|
85 | <table class=\"text\" width=\"50%\" style=\"height: 30px;\">
|
---|
86 | <tr class=\"table\">
|
---|
87 | <td align=\"center\" colspan=\"3\">
|
---|
88 | <a href=\"" . BX_DOL_URL_ADMIN . "notifies.php?action=empty\">{$sEmptyQueueC}</a>
|
---|
89 | </td>
|
---|
90 | </tr>
|
---|
91 | </table>
|
---|
92 | <hr>";
|
---|
93 | }
|
---|
94 |
|
---|
95 | ob_start();
|
---|
96 | ?>
|
---|
97 | <div style="margin:9px;">
|
---|
98 | <center>
|
---|
99 | <table cellspacing=2 cellpadding=2 class=text border=0>
|
---|
100 | <tr class=header align="center"><td><?=_t('_adm_mmail_Queue_status');?>:</td></tr>
|
---|
101 | <?=$sSingleEmailsTRs;?>
|
---|
102 | </table>
|
---|
103 | <?=$sEmptyQueueTable;?>
|
---|
104 | </center>
|
---|
105 | </div>
|
---|
106 | <?
|
---|
107 | $sResult = ob_get_clean();
|
---|
108 |
|
---|
109 | if(!empty($sActionResult))
|
---|
110 | $sResult = MsgBox($sActionResult, 3) . $sResult;
|
---|
111 |
|
---|
112 | return DesignBoxContent(_t('_Status'), $sResult, 1);
|
---|
113 | }
|
---|
114 |
|
---|
115 | function getAllMessagesBox() {
|
---|
116 | $aMessages = $GLOBALS['MySQL']->getAll("SELECT `id`, `subject`, (`id`=". (int)$_REQUEST['msgs_id'] ." OR `subject`='". process_db_input($_REQUEST['Subj']) ."' ) AS `selected` FROM `sys_sbs_messages`");
|
---|
117 |
|
---|
118 | $sAllMessagesOptions = '';
|
---|
119 | foreach($aMessages as $aMessage)
|
---|
120 | $sAllMessagesOptions .= "<option value=\"" . $aMessage['id'] . "\" " . ($aMessage['selected'] ? "selected=\"selected\"" : "") . ">" . $aMessage['subject'] . "</option>";
|
---|
121 |
|
---|
122 | ob_start();
|
---|
123 | ?>
|
---|
124 | <form name="form_messages" method="POST" action="<?=$_SERVER['PHP_SELF'];?>">
|
---|
125 | <input type="hidden" name="action" value="view">
|
---|
126 | <center class="text"><?= _t('_Messages'); ?>:
|
---|
127 | <select name=msgs_id onChange="javascript: document.forms['form_messages'].submit();">
|
---|
128 | <option value=0><?=_t('_None');?></option>
|
---|
129 | <?=$sAllMessagesOptions;?>
|
---|
130 | </select>
|
---|
131 | </center>
|
---|
132 | </form>
|
---|
133 | <?
|
---|
134 | $sResult = ob_get_clean();
|
---|
135 |
|
---|
136 | return DesignBoxContent(_t('_adm_mmail_All_Messages'), '<div style="margin:9px;">' . $sResult . '</div>', 1);
|
---|
137 | }
|
---|
138 |
|
---|
139 | function getEmailMessage($sAction) {
|
---|
140 | $sErrorC = _t('_Error Occured');
|
---|
141 | $sApplyChangesC = _t('_Submit');
|
---|
142 | $sSubjectC = _t('_Subject');
|
---|
143 | $sBodyC = _t('_adm_mmail_Body');
|
---|
144 | $sTextBodyC = _t('_adm_mmail_Text_email_body');
|
---|
145 | $sPreviewMessageC = _t('_Preview');
|
---|
146 | $sDeleteC = _t('_Delete');
|
---|
147 |
|
---|
148 | $sMessageID = (int)$_REQUEST['msgs_id'];
|
---|
149 |
|
---|
150 | $sSubject = $sBody = "";
|
---|
151 | if ( $_REQUEST['body'] && $_REQUEST['action'] != 'delete' ) {
|
---|
152 | $sSubject = process_pass_data( $_REQUEST['subject'] );
|
---|
153 | $sBody = process_pass_data( $_REQUEST['body'] );
|
---|
154 | } elseif ( $sMessageID )
|
---|
155 | list($sSubject, $sBody) = $GLOBALS['MySQL']->getRow("SELECT `subject`, `body` FROM `sys_sbs_messages` WHERE `id`='". $sMessageID . "' LIMIT 1", MYSQL_NUM);
|
---|
156 |
|
---|
157 | $sSubject = htmlspecialchars($sSubject);
|
---|
158 |
|
---|
159 | $aForm = array(
|
---|
160 | 'form_attrs' => array(
|
---|
161 | 'name' => 'sys_sbs_messages',
|
---|
162 | 'action' => $_SERVER['PHP_SELF'],
|
---|
163 | 'method' => 'post',
|
---|
164 | ),
|
---|
165 | 'params' => array (
|
---|
166 | 'db' => array(
|
---|
167 | 'table' => 'sys_sbs_messages',
|
---|
168 | 'key' => 'ID',
|
---|
169 | 'submit_name' => 'add_message',
|
---|
170 | ),
|
---|
171 | ),
|
---|
172 | 'inputs' => array(
|
---|
173 | 'subject' => array(
|
---|
174 | 'type' => 'text',
|
---|
175 | 'name' => 'subject',
|
---|
176 | 'value' => $sSubject,
|
---|
177 | 'caption' => $sSubjectC,
|
---|
178 | 'required' => true,
|
---|
179 | 'checker' => array (
|
---|
180 | 'func' => 'length',
|
---|
181 | 'params' => array(2,128),
|
---|
182 | 'error' => $sErrorC,
|
---|
183 | ),
|
---|
184 | 'db' => array (
|
---|
185 | 'pass' => 'Xss',
|
---|
186 | ),
|
---|
187 | ),
|
---|
188 | 'body' => array(
|
---|
189 | 'type' => 'textarea',
|
---|
190 | 'name' => 'body',
|
---|
191 | 'value' => $sBody,
|
---|
192 | 'caption' => $sBodyC,
|
---|
193 | 'required' => true,
|
---|
194 | 'html' => 1,
|
---|
195 | 'checker' => array (
|
---|
196 | 'func' => 'length',
|
---|
197 | 'params' => array(10,32000),
|
---|
198 | 'error' => $sErrorC,
|
---|
199 | ),
|
---|
200 | 'db' => array (
|
---|
201 | 'pass' => 'XssHtml',
|
---|
202 | ),
|
---|
203 | ),
|
---|
204 | 'msgs_id' => array(
|
---|
205 | 'type' => 'hidden',
|
---|
206 | 'name' => 'msgs_id',
|
---|
207 | 'value' => $sMessageID,
|
---|
208 | ),
|
---|
209 | 'control' => array (
|
---|
210 | 'type' => 'input_set',
|
---|
211 | array(
|
---|
212 | 'type' => 'submit',
|
---|
213 | 'name' => 'add_message',
|
---|
214 | 'caption' => $sApplyChangesC,
|
---|
215 | 'value' => $sApplyChangesC,
|
---|
216 | ),
|
---|
217 | array(
|
---|
218 | 'type' => 'submit',
|
---|
219 | 'name' => 'preview_message',
|
---|
220 | 'caption' => $sPreviewMessageC,
|
---|
221 | 'value' => $sPreviewMessageC,
|
---|
222 | ),
|
---|
223 | )
|
---|
224 | ),
|
---|
225 | );
|
---|
226 | if($sMessageID) {
|
---|
227 | $aForm['inputs']['control'][] = array (
|
---|
228 | 'type' => 'submit',
|
---|
229 | 'name' => 'delete_message',
|
---|
230 | 'caption' => $sDeleteC,
|
---|
231 | 'value' => $sDeleteC,
|
---|
232 | );
|
---|
233 | }
|
---|
234 |
|
---|
235 | $sResult = '';
|
---|
236 | $oForm = new BxTemplFormView($aForm);
|
---|
237 | $oForm->initChecker();
|
---|
238 | if ($oForm->isSubmittedAndValid()) {
|
---|
239 | if ($sAction == 'add') {
|
---|
240 | if ($sMessageID > 0) {
|
---|
241 | $oForm->update($sMessageID);
|
---|
242 | } else {
|
---|
243 | $sMessageID = $oForm->insert();
|
---|
244 | }
|
---|
245 | }
|
---|
246 |
|
---|
247 | $sResult = $sMessageID > 0 ? MsgBox(_t('_Success'), 3) : MsgBox($sErrorC);
|
---|
248 | }
|
---|
249 |
|
---|
250 | return DesignBoxContent(_t('_adm_mmail_Email_message'), '<div style="margin:9px;">' . $sResult . $oForm->getCode() . '</div>', 1);
|
---|
251 | }
|
---|
252 |
|
---|
253 | function getQueueMessage() {
|
---|
254 | global $aPreValues;
|
---|
255 |
|
---|
256 | if ( $_REQUEST['msgs_id'] ) {
|
---|
257 | $aSexValues = getFieldValues('Sex');
|
---|
258 | foreach($aSexValues as $sKey => $sValue)
|
---|
259 | $aSexValues[$sKey] = _t($sValue);
|
---|
260 |
|
---|
261 | $aStartAgesOptions = array();
|
---|
262 | $aEndAgesOptions = array();
|
---|
263 | $gl_search_start_age = (int)getParam('search_start_age');
|
---|
264 | $gl_search_end_age = (int)getParam('search_end_age');
|
---|
265 | for ( $i = $gl_search_start_age ; $i <= $gl_search_end_age ; $i++ ) {
|
---|
266 | $aStartAgesOptions[$i] = $i;
|
---|
267 | }
|
---|
268 | for ( $i = $gl_search_start_age ; $i <= $gl_search_end_age ; $i++ ) {
|
---|
269 | $aEndAgesOptions[$i] = $i;
|
---|
270 | }
|
---|
271 |
|
---|
272 | $aCountryOptions = array('all' => _t('_All'));
|
---|
273 | foreach ( $aPreValues['Country'] as $key => $value ) {
|
---|
274 | $aCountryOptions[$key] = _t($value['LKey']);
|
---|
275 | }
|
---|
276 |
|
---|
277 | $aMembershipOptions = array('all' => _t('_All'));
|
---|
278 | $memberships_arr = getMemberships();
|
---|
279 | foreach ( $memberships_arr as $membershipID => $membershipName ) {
|
---|
280 | if ($membershipID == MEMBERSHIP_ID_NON_MEMBER) continue;
|
---|
281 | $aMembershipOptions[$membershipID] = $membershipName;
|
---|
282 | }
|
---|
283 |
|
---|
284 | $aForm = array(
|
---|
285 | 'form_attrs' => array(
|
---|
286 | 'name' => 'form_queue',
|
---|
287 | 'class' => 'form_queue_form',
|
---|
288 | 'action' => $_SERVER['PHP_SELF'],
|
---|
289 | 'method' => 'post',
|
---|
290 | ),
|
---|
291 | 'inputs' => array (
|
---|
292 | 'Send1' => array(
|
---|
293 | 'type' => 'checkbox',
|
---|
294 | 'name' => 'send_to_subscribers',
|
---|
295 | 'label' => _t('_adm_mmail_Send_to_subscribers'),
|
---|
296 | 'value' => 'non',
|
---|
297 | 'checked' => true
|
---|
298 | ),
|
---|
299 | 'Send2' => array(
|
---|
300 | 'type' => 'checkbox',
|
---|
301 | 'name' => 'send_to_members',
|
---|
302 | 'label' => _t('_adm_mmail_Send_to_members'),
|
---|
303 | 'value' => 'memb',
|
---|
304 | 'checked' => true,
|
---|
305 | 'attrs' => array(
|
---|
306 | 'onClick' => 'setControlsState();',
|
---|
307 | )
|
---|
308 | ),
|
---|
309 | 'sex' => array (
|
---|
310 | 'type' => 'checkbox_set',
|
---|
311 | 'name' => 'sex',
|
---|
312 | 'values' => $aSexValues,
|
---|
313 | 'value' => array_keys($aSexValues)
|
---|
314 | ),
|
---|
315 | 'StartAge' => array (
|
---|
316 | 'type' => 'select',
|
---|
317 | 'name' => 'age_start',
|
---|
318 | 'caption' => _t('_adm_mmail_Age') . ' ' . _t('_from'),
|
---|
319 | 'values' => $aStartAgesOptions,
|
---|
320 | 'value' => $gl_search_start_age,
|
---|
321 | ),
|
---|
322 | 'EndAge' => array (
|
---|
323 | 'type' => 'select',
|
---|
324 | 'name' => 'age_end',
|
---|
325 | 'caption' => _t('_to'),
|
---|
326 | 'values' => $aEndAgesOptions,
|
---|
327 | 'value' => $gl_search_end_age,
|
---|
328 | ),
|
---|
329 | 'Country' => array (
|
---|
330 | 'type' => 'select',
|
---|
331 | 'name' => 'country',
|
---|
332 | 'caption' => _t('_Country'),
|
---|
333 | 'values' => $aCountryOptions,
|
---|
334 | 'value' => 'all',
|
---|
335 | ),
|
---|
336 | 'Membership' => array (
|
---|
337 | 'type' => 'select',
|
---|
338 | 'name' => 'membership',
|
---|
339 | 'caption' => _t('_adm_mmi_membership_levels'),
|
---|
340 | 'values' => $aMembershipOptions,
|
---|
341 | 'value' => 'all',
|
---|
342 | ),
|
---|
343 | 'msgs_id' => array (
|
---|
344 | 'type' => 'hidden',
|
---|
345 | 'name' => 'msgs_id',
|
---|
346 | 'value' => (int)$_REQUEST['msgs_id'],
|
---|
347 | ),
|
---|
348 | 'submit' => array (
|
---|
349 | 'type' => 'submit',
|
---|
350 | 'name' => 'queue_message',
|
---|
351 | 'value' => _t('_Submit'),
|
---|
352 | )
|
---|
353 | )
|
---|
354 | );
|
---|
355 |
|
---|
356 | $oForm = new BxTemplFormView($aForm);
|
---|
357 | $sTmplResult = $GLOBALS['oAdmTemplate']->parseHtmlByName('notifies_filter.html', array());
|
---|
358 | return DesignBoxContent(_t('_adm_mmail_Queue_message'), '<div style="margin:9px;">' . $oForm->getCode() . $sTmplResult . '</div>', 1);
|
---|
359 | }
|
---|
360 | }
|
---|
361 |
|
---|
362 | function QueueMessage() {
|
---|
363 | global $MySQL;
|
---|
364 |
|
---|
365 | $iEmails = 0;
|
---|
366 | $sReturn = "";
|
---|
367 | $iMsgId = (int)$_REQUEST['msgs_id'];
|
---|
368 |
|
---|
369 | $aMessage = $MySQL->getRow("SELECT `id`, `subject`, `body` FROM `sys_sbs_messages` WHERE `id`='" . $iMsgId . "' LIMIT 1");
|
---|
370 | if(!is_array($aMessage) || empty($aMessage)) {
|
---|
371 | return _t('_adm_mmail_Failed_to_queue_emails_X', $iMsgId);
|
---|
372 | }
|
---|
373 |
|
---|
374 | //--- Send to all subscribers
|
---|
375 | $oEmailTemplates = new BxDolEmailTemplates();
|
---|
376 | if($_REQUEST['send_to_subscribers'] == 'non') {
|
---|
377 | $sSql = "SELECT
|
---|
378 | `tsu`.`name` AS `user_name`,
|
---|
379 | `tsu`.`email` AS `user_email`,
|
---|
380 | `tst`.`template` AS `template_name`
|
---|
381 | FROM `sys_sbs_types` AS `tst`
|
---|
382 | INNER JOIN `sys_sbs_entries` AS `tse` ON `tst`.`id`=`tse`.`subscription_id` AND `tse`.`subscriber_type`='" . BX_DOL_SBS_TYPE_VISITOR . "'
|
---|
383 | INNER JOIN `sys_sbs_users` AS `tsu` ON `tse`.`subscriber_id`=`tsu`.`id`
|
---|
384 | WHERE
|
---|
385 | `tst`.`unit`='system' AND
|
---|
386 | `tst`.`action`='mass_mailer'";
|
---|
387 | $aSubscribers = $MySQL->getAll($sSql);
|
---|
388 |
|
---|
389 | foreach($aSubscribers as $aSubscriber) {
|
---|
390 | $aMessage = $oEmailTemplates->parseTemplate($aSubscriber['template_name'], array(
|
---|
391 | 'RealName' => $aSubscriber['user_name'],
|
---|
392 | 'Email' => $aSubscriber['user_email'],
|
---|
393 | 'MessageSubject' => $aMessage['subject'],
|
---|
394 | 'MessageText' => $aMessage['body']
|
---|
395 | ));
|
---|
396 |
|
---|
397 | $mixedResult = $MySQL->query("INSERT INTO `sys_sbs_queue`(`email`, `subject`, `body`) VALUES('" . $aSubscriber['user_email'] . "', '" . process_db_input($aMessage['subject'], BX_TAGS_STRIP) . "', '" . process_db_input($aMessage['body'], BX_TAGS_VALIDATE) . "')");
|
---|
398 | if($mixedResult === false) {
|
---|
399 | $sReturn .= _t('_adm_mmail_Email_not_added_to_queue_X', $aSubscriber['user_email']);
|
---|
400 | continue;
|
---|
401 | }
|
---|
402 | $iEmails++;
|
---|
403 | }
|
---|
404 | }
|
---|
405 |
|
---|
406 | //--- Send to all profiles
|
---|
407 | if($_REQUEST['send_to_members'] == 'memb') {
|
---|
408 | //--- Sex filter
|
---|
409 | $sex_filter_sql = '';
|
---|
410 | if(is_array($_REQUEST['sex']) && !empty($_REQUEST['sex']))
|
---|
411 | $sex_filter_sql = "AND `Sex` IN ('" . implode("','", $_REQUEST['sex']) . "')";
|
---|
412 |
|
---|
413 | //--- Age filter
|
---|
414 | $age_filter_sql = '';
|
---|
415 | $age_start = (int)$_REQUEST['age_start'];
|
---|
416 | $age_end = (int)$_REQUEST['age_end'];
|
---|
417 | if ( $age_start && $age_end ) {
|
---|
418 | $date_start = (int)( date( "Y" ) - $age_start );
|
---|
419 | $date_end = (int)( date( "Y" ) - $age_end - 1 );
|
---|
420 | $date_start = $date_start . date( "-m-d" );
|
---|
421 | $date_end = $date_end . date( "-m-d" );
|
---|
422 | $age_filter_sql = "AND (TO_DAYS(`DateOfBirth`) BETWEEN TO_DAYS('{$date_end}') AND (TO_DAYS('{$date_start}')+1))";
|
---|
423 | }
|
---|
424 |
|
---|
425 | //--- Country filter
|
---|
426 | $country_filter_sql = '';
|
---|
427 | if($_REQUEST['country'] != 'all') {
|
---|
428 | $country = process_db_input($_REQUEST['country']);
|
---|
429 | $country_filter_sql = "AND `Country` = '{$country}'";
|
---|
430 | }
|
---|
431 |
|
---|
432 | //--- Membership filter
|
---|
433 | $membershipID = $_REQUEST['membership'] != 'all' ? (int)$_REQUEST['membership'] : -1;
|
---|
434 |
|
---|
435 | $aMembers = $MySQL->getAll("SELECT `ID` AS `id`, `Email` AS `email` FROM `Profiles` WHERE `Status` <> 'Unconfirmed' AND `EmailNotify` = 1 {$sex_filter_sql} {$age_filter_sql} {$country_filter_sql}");
|
---|
436 | foreach($aMembers as $aMember) {
|
---|
437 | //--- Dynamic membership filter
|
---|
438 | $membership_info = getMemberMembershipInfo($aMember['id']);
|
---|
439 | if ($membershipID != -1 && $membership_info['ID'] != $membershipID )
|
---|
440 | continue;
|
---|
441 |
|
---|
442 | $aMessageResult = $oEmailTemplates->parseTemplate('t_AdminEmail', array(
|
---|
443 | 'MessageSubject' => $aMessage['subject'],
|
---|
444 | 'MessageText' => $aMessage['body']
|
---|
445 | ), $aMember['id']);
|
---|
446 |
|
---|
447 | $mixedResult = $MySQL->query("INSERT INTO `sys_sbs_queue`(`email`, `subject`, `body`) VALUES('" . $aMember['email'] . "', '" . process_db_input($aMessageResult['subject'], BX_TAGS_STRIP) . "', '" . process_db_input($aMessageResult['body'], BX_TAGS_VALIDATE) . "')");
|
---|
448 | if($mixedResult === false) {
|
---|
449 | $sReturn .= _t('_adm_mmail_Email_not_added_to_queue_X', $aMember['email']);
|
---|
450 | continue;
|
---|
451 | }
|
---|
452 | $iEmails++;
|
---|
453 | }
|
---|
454 | }
|
---|
455 |
|
---|
456 | $sReturn .= _t('_adm_mmail_X_emails_was_succ_added_to_queue', (int)$iEmails);
|
---|
457 | return $sReturn;
|
---|
458 | }
|
---|
459 |
|
---|
460 | function PreviewMessage() {
|
---|
461 | $oEmailTemplate = new BxDolEmailTemplates();
|
---|
462 | $aMessage = $oEmailTemplate->parseTemplate('t_AdminEmail', array(
|
---|
463 | 'MessageText' => process_pass_data($_REQUEST['body'])
|
---|
464 | ));
|
---|
465 |
|
---|
466 | $sPreview = '<div style="margin:9px;">' . $aMessage['body'] . '</div>';
|
---|
467 | return DesignBoxContent(_t('_Preview'), $sPreview, 1);
|
---|
468 | }
|
---|
469 |
|
---|
470 | function DeleteMessage() {
|
---|
471 | $mixedResult = $GLOBALS['MySQL']->query("DELETE FROM `sys_sbs_messages` WHERE `id`='". (int)$_REQUEST['msgs_id'] . "' LIMIT 1");
|
---|
472 | if($mixedResult === false)
|
---|
473 | return $mixedResult;
|
---|
474 |
|
---|
475 | $_REQUEST['msgs_id'] = 0;
|
---|
476 | return true;
|
---|
477 | }
|
---|
478 |
|
---|
479 | function EmptyQueue() {
|
---|
480 | return db_res("TRUNCATE TABLE `sys_sbs_queue`");
|
---|
481 | }
|
---|
482 |
|
---|
483 | ?>
|
---|