| 1432 | | |
|---|
| 1433 | | $sql = "SELECT u.uid, u.email, u.language, u.notifs |
|---|
| 1434 | | FROM " . COMMENTS_NOTIFY_TABLE . " tw, " . USERS_TABLE . " u |
|---|
| 1435 | | WHERE tw.checkcomm_for_id = " . $for_id . " |
|---|
| 1436 | | AND tw.checkcomm_userid NOT IN (" . $userdata['uid'] . ", " . ANONYMOUS . ") |
|---|
| 1437 | | AND tw.checkcomm_notify_status = " . NOTIFY_STATUS_UN_NOTIFIED . " |
|---|
| 1438 | | AND u.uid = tw.checkcomm_userid |
|---|
| 1439 | | AND u.enabled = 1 |
|---|
| 1440 | | AND tw.checkcomm_type = " . $notify_type; |
|---|
| 1441 | | $result = $db->sql_query($sql); |
|---|
| 1442 | | |
|---|
| 1443 | | $update_watched_sql = ''; |
|---|
| 1444 | | $bcc_list_ary = array(); |
|---|
| 1445 | | |
|---|
| 1446 | | if ( $row = $db->sql_fetchrow($result) ) { |
|---|
| 1447 | | // Sixty second limit |
|---|
| 1448 | | @set_time_limit(60); |
|---|
| 1449 | | |
|---|
| 1450 | | do |
|---|
| 1451 | | { |
|---|
| 1452 | | if ( strpos($row['notifs'], $notifs_type) !== false ) |
|---|
| | 1432 | if ( $info_data['mode'] == 'reply' ) { |
|---|
| | 1433 | |
|---|
| | 1434 | $sql = "SELECT u.uid, u.email, u.language, u.notifs |
|---|
| | 1435 | FROM " . COMMENTS_NOTIFY_TABLE . " tw, " . USERS_TABLE . " u |
|---|
| | 1436 | WHERE tw.checkcomm_for_id = " . $for_id . " |
|---|
| | 1437 | AND tw.checkcomm_userid NOT IN (" . $userdata['uid'] . ", " . ANONYMOUS . ") |
|---|
| | 1438 | AND tw.checkcomm_notify_status = " . NOTIFY_STATUS_UN_NOTIFIED . " |
|---|
| | 1439 | AND u.uid = tw.checkcomm_userid |
|---|
| | 1440 | AND u.enabled = 1 |
|---|
| | 1441 | AND tw.checkcomm_type = " . $notify_type; |
|---|
| | 1442 | $result = $db->sql_query($sql); |
|---|
| | 1443 | |
|---|
| | 1444 | $update_watched_sql = ''; |
|---|
| | 1445 | $bcc_list_ary = array(); |
|---|
| | 1446 | |
|---|
| | 1447 | if ( $row = $db->sql_fetchrow($result) ) { |
|---|
| | 1448 | // Sixty second limit |
|---|
| | 1449 | @set_time_limit(60); |
|---|
| | 1450 | |
|---|
| | 1451 | do |
|---|
| 1454 | | $bcc_list_ary[$row['language']][] = $row['email']; |
|---|
| 1455 | | } |
|---|
| 1456 | | $update_watched_sql .= ($update_watched_sql != '') ? ', ' . $row['uid'] : $row['uid']; |
|---|
| 1457 | | } |
|---|
| 1458 | | while ( $row = $db->sql_fetchrow($result) ); |
|---|
| 1459 | | |
|---|
| 1460 | | if ( sizeof($bcc_list_ary) ) |
|---|
| 1461 | | { |
|---|
| 1462 | | include_once($root_path . 'include/functions_messenger.php'); |
|---|
| 1463 | | $messenger = new messenger(true); |
|---|
| 1464 | | |
|---|
| 1465 | | foreach ( $bcc_list_ary AS $user_lang => $bcc_list ) { |
|---|
| 1466 | | |
|---|
| 1467 | | foreach ( $bcc_list AS $_null => $email ) { |
|---|
| 1468 | | |
|---|
| 1469 | | $messenger->template($email_template, $user_lang); |
|---|
| 1470 | | |
|---|
| 1471 | | $messenger->to($email, $email); |
|---|
| 1472 | | |
|---|
| 1473 | | $messenger->assign_vars(array( |
|---|
| 1474 | | 'TITLE' => $title, |
|---|
| 1475 | | 'U_VIEW_URL' => $u_view_url, |
|---|
| 1476 | | 'U_STOP_WATCHING' => $u_stop_watching |
|---|
| 1477 | | )); |
|---|
| 1478 | | |
|---|
| 1479 | | $messenger->send(NOTIFY_EMAIL); |
|---|
| | 1453 | if ( strpos($row['notifs'], $notifs_type) !== false ) |
|---|
| | 1454 | { |
|---|
| | 1455 | $bcc_list_ary[$row['language']][] = $row['email']; |
|---|
| 1481 | | } |
|---|
| 1482 | | $messenger->save_queue(); |
|---|
| 1483 | | } |
|---|
| 1484 | | } |
|---|
| 1485 | | $db->sql_freeresult($result); |
|---|
| 1486 | | |
|---|
| 1487 | | if ( $update_watched_sql ) |
|---|
| 1488 | | { |
|---|
| 1489 | | $sql = 'UPDATE ' . COMMENTS_NOTIFY_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array( |
|---|
| 1490 | | 'checkcomm_notify_status' => NOTIFY_STATUS_NOTIFIED, |
|---|
| 1491 | | 'checkcomm_last_comment_id' => $last_id, |
|---|
| 1492 | | 'checkcomm_view_status' => VIEW_STATUS_NOT_VIEWED, |
|---|
| 1493 | | )) . ' |
|---|
| 1494 | | WHERE checkcomm_for_id = ' . $for_id . ' |
|---|
| 1495 | | AND checkcomm_type = ' . $notify_type . ' |
|---|
| 1496 | | AND checkcomm_userid IN (' . $update_watched_sql . ')'; |
|---|
| 1497 | | $db->sql_query($sql); |
|---|
| | 1457 | $update_watched_sql .= ($update_watched_sql != '') ? ', ' . $row['uid'] : $row['uid']; |
|---|
| | 1458 | } |
|---|
| | 1459 | while ( $row = $db->sql_fetchrow($result) ); |
|---|
| | 1460 | |
|---|
| | 1461 | if ( sizeof($bcc_list_ary) ) |
|---|
| | 1462 | { |
|---|
| | 1463 | include_once($root_path . 'include/functions_messenger.php'); |
|---|
| | 1464 | $messenger = new messenger(true); |
|---|
| | 1465 | |
|---|
| | 1466 | foreach ( $bcc_list_ary AS $user_lang => $bcc_list ) { |
|---|
| | 1467 | |
|---|
| | 1468 | foreach ( $bcc_list AS $_null => $email ) { |
|---|
| | 1469 | |
|---|
| | 1470 | $messenger->template($email_template, $user_lang); |
|---|
| | 1471 | |
|---|
| | 1472 | $messenger->to($email, $email); |
|---|
| | 1473 | |
|---|
| | 1474 | $messenger->assign_vars(array( |
|---|
| | 1475 | 'TITLE' => $title, |
|---|
| | 1476 | 'U_VIEW_URL' => $u_view_url, |
|---|
| | 1477 | 'U_STOP_WATCHING' => $u_stop_watching |
|---|
| | 1478 | )); |
|---|
| | 1479 | |
|---|
| | 1480 | $messenger->send(NOTIFY_EMAIL); |
|---|
| | 1481 | } |
|---|
| | 1482 | } |
|---|
| | 1483 | $messenger->save_queue(); |
|---|
| | 1484 | } |
|---|
| | 1485 | } |
|---|
| | 1486 | $db->sql_freeresult($result); |
|---|
| | 1487 | |
|---|
| | 1488 | if ( $update_watched_sql ) |
|---|
| | 1489 | { |
|---|
| | 1490 | $sql = 'UPDATE ' . COMMENTS_NOTIFY_TABLE . ' SET ' . $db->sql_build_array('UPDATE', array( |
|---|
| | 1491 | 'checkcomm_notify_status' => NOTIFY_STATUS_NOTIFIED, |
|---|
| | 1492 | 'checkcomm_last_comment_id' => $last_id, |
|---|
| | 1493 | 'checkcomm_view_status' => VIEW_STATUS_NOT_VIEWED, |
|---|
| | 1494 | )) . ' |
|---|
| | 1495 | WHERE checkcomm_for_id = ' . $for_id . ' |
|---|
| | 1496 | AND checkcomm_type = ' . $notify_type . ' |
|---|
| | 1497 | AND checkcomm_userid IN (' . $update_watched_sql . ')'; |
|---|
| | 1498 | $db->sql_query($sql); |
|---|
| | 1499 | } |
|---|