$moderators[$moderator_ID] = array();
        }
        $moderators[$moderator_ID][$blog_ID] = array('perm_edit' => $max_perm_edit, 'perm_statuses' => $max_perm_statuses);
    }
}
// Set notify moderation condition
$def_send_moderation_reminder = $UserSettings->get('send_cmt_moderation_reminder');
if ($def_send_moderation_reminder) {
    // Send comment moderation reminder is set by default
    $send_moderation_reminder_cond = '( ( uset_value IS NOT NULL AND uset_value <> \'0\' ) OR ( uset_value IS NULL ) )';
} else {
    // Send comment moderation reminder is NOT set by default
    $send_moderation_reminder_cond = '( uset_value IS NOT NULL AND uset_value <> \'0\' )';
}
// Select blocked and spam email addresses to prevent sending emails to them
$blocked_emails = $DB->get_col('SELECT emblk_address FROM T_email__blocked WHERE ' . get_mail_blocked_condition());
$blocked_emails_condition = count($blocked_emails) ? 'user_email NOT IN ( "' . implode('","', $blocked_emails) . '" )' : NULL;
// load all required Users ( global moderators, blog owners and users with advanced blog perms )
$all_required_users = array_unique(array_merge($global_moderators, array_keys($moderators)));
$SQL = new SQL();
$SQL->SELECT('T_users.*');
$SQL->FROM('T_users');
$SQL->FROM_add('LEFT JOIN T_users__usersettings ON uset_user_ID = user_ID AND uset_name = "send_cmt_moderation_reminder"');
$SQL->WHERE('user_ID IN (' . implode(',', $all_required_users) . ')');
$SQL->WHERE_and($send_moderation_reminder_cond);
$SQL->WHERE_and('LENGTH(TRIM(user_email)) > 0');
$SQL->WHERE_and($blocked_emails_condition);
// Load moderator users who would like to get notificaions
$UserCache =& get_UserCache();
$UserCache->clear(true);
$UserCache->load_by_sql($SQL);
    $reminder_delay_conditions[] = '( last_sent.uset_value < ' . $DB->quote($reminder_date) . ' AND reminder_sent.uset_value = ' . $DB->quote($i) . ' )';
}
$failed_activation_threshold = $activate_account_reminder_config[$number_of_max_reminders];
$SQL = new SQL();
$SQL->SELECT('T_users.*');
$SQL->FROM('T_users');
// join UserSettings
$SQL->FROM_add('LEFT JOIN T_users__usersettings last_sent ON last_sent.uset_user_ID = user_ID AND last_sent.uset_name = "last_activation_email"');
$SQL->FROM_add('LEFT JOIN T_users__usersettings notif_setting ON notif_setting.uset_user_ID = user_ID AND notif_setting.uset_name = "send_activation_reminder"');
$SQL->FROM_add('LEFT JOIN T_users__usersettings reminder_sent ON reminder_sent.uset_user_ID = user_ID AND reminder_sent.uset_name = "activation_reminder_count"');
// check that user status is 'new' or 'emailchanged' or 'deactivated', and send reminders only for these users.
$SQL->WHERE($status_condition);
// check if user has an email address
$SQL->WHERE_and('LENGTH(TRIM(user_email)) > 0');
// check that user email is not blocked
$SQL->WHERE_and('user_email NOT IN ( SELECT emadr_address FROM T_email__address WHERE ' . get_mail_blocked_condition() . ' )');
// check that user was created more than x ( = confugred activate account reminder threshold ) seconds ago!
$threshold_date = date2mysql($servertimenow - $activate_account_reminder_threshold);
$SQL->WHERE_and('user_created_datetime < ' . $DB->quote($threshold_date));
// check how many reminders was sent to the user and when => send reminders only if required
$SQL->WHERE_and(implode(' OR ', $reminder_delay_conditions));
// check if user wants to recevice activation reminder or not
$SQL->WHERE_and('notif_setting.uset_value IS NULL OR notif_setting.uset_value <> ' . $DB->quote('0'));
$UserCache =& get_UserCache();
$UserCache->clear();
// load all users to reminded into the UserCache
$UserCache->load_by_sql($SQL);
// Send activation reminder to every user loaded into the UserCache ( there are only not activated users )
$reminder_sent = send_easy_validate_emails($UserCache->get_ID_array());
// Set failed activation status for all users who didn't receive activation reminder or account validation email in the last seven days,
// and user was created more then a week, and have received at least one activation email.
    // by default everybody should be notified, so notify those users who didn't explicitly set to not receive notifications
    $notify_condition .= ' OR notif_setting.uset_value IS NULL';
}
// Find user who have unread messages created more than x ( = configured threshold value ) hours ago, and have not been reminded in the last y ( = configured reminder delay for this user ) hours
// We needs to send reminder for these users, but the message must include all unread threads even if the last unread messages was created less then x hours
$query = 'SELECT DISTINCT user_ID, last_sent.uset_value
		FROM T_users
			INNER JOIN T_messaging__threadstatus ON tsta_user_ID = user_ID
			INNER JOIN T_messaging__message ON tsta_first_unread_msg_ID = msg_ID
			LEFT JOIN T_users__usersettings last_sent ON last_sent.uset_user_ID = user_ID AND last_sent.uset_name = "last_unread_messages_reminder"
			LEFT JOIN T_users__usersettings notif_setting ON notif_setting.uset_user_ID = user_ID AND notif_setting.uset_name = "notify_unread_messages"
		WHERE ( msg_datetime < ' . $DB->quote($threshold_date) . ' )
			AND ( last_sent.uset_value IS NULL OR last_sent.uset_value < ' . $DB->quote($reminder_threshold) . ' )
			AND ( ' . $notify_condition . ' )
			AND ( LENGTH(TRIM(user_email)) > 0 )
			AND ( user_email NOT IN ( SELECT emblk_address FROM T_email__blocked WHERE ' . get_mail_blocked_condition() . ' ) )';
$users_to_remind = $DB->get_assoc($query, 0, 'Find users who need to be reminded');
if (empty($users_to_remind)) {
    // There is no user to remind
    $result_message = T_('It was not necessary to send any reminder!');
    return 1;
}
// load all required users into the cache
$UserCache =& get_UserCache();
$users_to_remind_ids = array_keys($users_to_remind);
$UserCache->load_list($users_to_remind_ids);
// Filter out those users which wasn't logged in since many days and shouldn't get reminder email in every three days
$index = -1;
foreach ($users_to_remind as $user_ID => $last_reminder_ts) {
    $index++;
    if (empty($last_reminder_ts)) {
Example #4
0
/**
 * Check if the email address is blocked
 *
 * @param string Email address
 * @param array Blocked statuses to know what emails are blocked to send
 *     'unknown'     - Unknown
 *     'warning'     - Warning
 *     'suspicious1' - Suspicious 1
 *     'suspicious2' - Suspicious 2
 *     'suspicious3' - Suspicious 3
 *     'prmerror'    - Permament error
 *     'spammer'     - Spammer
 * @return boolean TRUE
 */
function mail_is_blocked($email, $blocked_statuses = array())
{
    global $cache_mail_is_blocked_status;
    if (!isset($cache_mail_is_blocked_status)) {
        // Init array first time
        $cache_mail_is_blocked_status = array();
    }
    $status_filter_name = implode('_', $blocked_statuses);
    if (!isset($cache_mail_is_blocked_status[$status_filter_name])) {
        // Init subarray for each filter by statuses
        $cache_mail_is_blocked_status[$status_filter_name] = array();
    }
    if (!isset($cache_mail_is_blocked_status[$status_filter_name][$email])) {
        // If we check status of this email first time - get it from DB and store in cache
        global $DB;
        $SQL = new SQL();
        $SQL->SELECT('emadr_ID');
        $SQL->FROM('T_email__address');
        $SQL->WHERE('emadr_address = ' . $DB->quote(utf8_strtolower($email)));
        $SQL->WHERE_and(get_mail_blocked_condition(true, $blocked_statuses));
        $cache_mail_is_blocked_status[$status_filter_name][$email] = (bool) $DB->get_var($SQL->get());
    }
    // Get email block status from cache variable
    return $cache_mail_is_blocked_status[$status_filter_name][$email];
}