$UserSettings = new UserSettings();
}
// Only those blogs are selected for moderation where we can find at least one comment awaiting moderation which is older then the threshold date defined below
$threshold_date = date2mysql($servertimenow - $comment_moderation_reminder_threshold);
// Statuses defined in this array should be notified. This should be configurable, but this is the default value.
$notify_statuses = get_visibility_statuses('moderation');
// Select blogs where are comments awaiting moderation more then x ( = configured threshold ) hours
$SQL = new SQL();
$SQL->SELECT('DISTINCT cat_blog_ID');
$SQL->FROM('T_categories');
$SQL->FROM_add('INNER JOIN T_items__item ON post_main_cat_ID = cat_ID AND post_status IN (' . $DB->quote(array('published', 'community', 'protected')) . ')');
$SQL->FROM_add('INNER JOIN T_comments ON comment_post_ID = post_ID AND comment_status IN (' . $DB->quote($notify_statuses) . ') AND comment_date < ' . $DB->quote($threshold_date));
$moderation_blogs = $DB->get_col($SQL->get());
if (empty($moderation_blogs)) {
    // There are no blogs where exists draft comments older then the threshold ( 24 hours by default )
    $result_message = sprintf(T_('No comments have been awaiting moderation for more than %s.'), seconds_to_period($comment_moderation_reminder_threshold));
    return 1;
}
$moderation_blogs_cond = '%s IN ( ' . implode(',', $moderation_blogs) . ' )';
// Select global moderators
$SQL = new SQL();
$SQL->SELECT('user_ID');
$SQL->FROM('T_users');
$SQL->FROM_add('LEFT JOIN T_groups ON grp_ID = user_grp_ID');
$SQL->WHERE('grp_perm_blogs = ' . $DB->quote('editall'));
$global_moderators = $DB->get_col($SQL->get());
$not_global_moderator = count($global_moderators) ? '%s NOT IN ( ' . implode(',', $global_moderators) . ' )' : NULL;
// Select blog owners, because they are moderators in their own blogs
$SQL = new SQL();
$SQL->SELECT('blog_owner_user_ID, GROUP_CONCAT( DISTINCT cast(blog_ID as CHAR) ORDER BY blog_ID SEPARATOR \',\') as blogs');
$SQL->FROM('T_blogs');
Example #2
0
if ($cjob_repeat_after_hours = floor($cjob_row->ctsk_repeat_after % 86400 / 3600)) {
    $cjob_repeat_after .= $cjob_repeat_after_hours . ' ' . T_('hours') . ' ';
}
if ($cjob_repeat_after_minutes = floor($cjob_row->ctsk_repeat_after % 3600 / 60)) {
    $cjob_repeat_after .= $cjob_repeat_after_minutes . ' ' . T_('minutes');
}
$Form->info(T_('Repeat every'), $cjob_repeat_after);
$Form->end_fieldset();
$Form->begin_fieldset(T_('Execution details') . get_manual_link('scheduled-job-execution-details'));
if (empty($cjob_row->clog_status)) {
    $Form->info(T_('Status'), 'pending');
} else {
    $Form->info(T_('Status'), '<span class="cron_' . $cjob_row->clog_status . '">' . $cjob_row->clog_status . '</span>');
    $Form->info(T_('Real start time'), mysql2localedatetime($cjob_row->clog_realstart_datetime));
    $Form->info(T_('Real stop time'), mysql2localedatetime($cjob_row->clog_realstop_datetime));
    $Form->info(T_('Duration'), seconds_to_period(strtotime($cjob_row->clog_realstop_datetime) - strtotime($cjob_row->clog_realstart_datetime)));
    $cron_messages_data = @unserialize($cjob_row->clog_messages);
    if (!is_array($cron_messages_data)) {
        // Simple messages
        $Form->info(T_('Messages'), str_replace("\n", "<br />\n", $cjob_row->clog_messages));
    } else {
        // Serialized data
        if (isset($cron_messages_data['message'])) {
            // Display message
            $Form->info(T_('Messages'), str_replace("\n", "<br />\n", $cron_messages_data['message']));
        }
        if (isset($cron_messages_data['table_cols'], $cron_messages_data['table_data']) && !empty($cron_messages_data['table_data'])) {
            // Display table with report
            $Table = new Table(NULL, 'cron_');
            $Table->cols = array();
            if (!empty($cron_messages_data['table_cols'])) {
}
// Only those blogs are selected for moderation where we can find at least one post awaiting moderation which is older then the threshold date defined below
$threshold_date = date2mysql($servertimenow - $post_moderation_reminder_threshold);
// Statuses defined in this array should be notified. This should be configurable, but this is the default value.
$notify_statuses = get_visibility_statuses('moderation');
// Select blogs where are posts awaiting moderation more then x ( = configured threshold ) hours
$SQL = new SQL();
$SQL->SELECT('DISTINCT cat_blog_ID');
$SQL->FROM('T_categories');
$SQL->FROM_add('INNER JOIN T_items__item ON post_main_cat_ID = cat_ID');
$SQL->WHERE('post_status IN (' . $DB->quote($notify_statuses) . ')');
$SQL->WHERE_and('post_datecreated < ' . $DB->quote($threshold_date));
$moderation_blogs = $DB->get_col($SQL->get());
if (empty($moderation_blogs)) {
    // There are no blogs where exists draft posts older then the threshold ( 24 hours by default )
    $result_message = sprintf('No posts have been awaiting moderation for more than %s.', seconds_to_period($post_moderation_reminder_threshold));
    return 1;
}
$moderation_blogs_cond = '%s IN ( ' . implode(',', $moderation_blogs) . ' )';
// Select global moderators
$SQL = new SQL();
$SQL->SELECT('user_ID');
$SQL->FROM('T_users');
$SQL->FROM_add('LEFT JOIN T_groups ON grp_ID = user_grp_ID');
$SQL->WHERE('grp_perm_blogs = ' . $DB->quote('editall'));
$global_moderators = $DB->get_col($SQL->get());
$not_global_moderator = count($global_moderators) ? '%s NOT IN ( ' . implode(',', $global_moderators) . ' )' : NULL;
// Select blog owners, because they are moderators in their own blogs
$SQL = new SQL();
$SQL->SELECT('blog_owner_user_ID, GROUP_CONCAT( DISTINCT cast(blog_ID as CHAR) ORDER BY blog_ID SEPARATOR \',\') as blogs');
$SQL->FROM('T_blogs');
Example #4
0
/**
 * Get next 'Unread message reminder' datetime information for the given user. This is used on the user admin settings form.
 *
 * @param integer user ID
 * @result mixed string with the info field content if additional note is not required, and array( info, note ) otherwise
 */
function get_next_reminder_info($user_ID)
{
    global $UserSettings, $DB, $servertimenow, $unread_message_reminder_delay, $unread_messsage_reminder_threshold;
    if (!$UserSettings->get('notify_unread_messages', $user_ID)) {
        // The user doesn't want to recive unread messages reminders
        return T_('This user doesn\'t want to receive notification emails about unread messages.');
    }
    $first_unread_message_date = get_first_unread_message_date($user_ID);
    if (empty($first_unread_message_date)) {
        // The user doesn't have unread messages
        return T_('This user doesn\'t have unread messages.');
    }
    // We assume that reminder is not delayed because of the user was not logged in since too many days
    $reminder_is_delayed = false;
    $last_unread_messages_reminder = $UserSettings->get('last_unread_messages_reminder', $user_ID);
    if (empty($last_unread_messages_reminder)) {
        // User didn't get new message notification or unread message reminder yet
        // Set reminder issue timestamp to one day after the first unread message was received
        $reminder_issue_ts = strtotime('+1 day', strtotime($first_unread_message_date));
    } else {
        // Count next unread message reminder date, this can be delayed if the edited User didn't logged in since many days
        $UserCache =& get_UserCache();
        $edited_User =& $UserCache->get_by_ID($user_ID);
        $lastseen_ts = strtotime($edited_User->get('lastseen_ts'));
        $days_since_lastseen = floor(($servertimenow - $lastseen_ts) / (60 * 60 * 24));
        // Presuppose that the User was not logged in since so many days, that should not get reminder any more
        $dont_send_reminder = true;
        // Get the number of delayed days for that case when we have to space out the notifications
        foreach ($unread_message_reminder_delay as $lastseen => $delay) {
            // Get the corresponding number of delay for the edited User
            if ($days_since_lastseen < $lastseen) {
                // We have found the correct delay value, reminders should be sent
                $dont_send_reminder = false;
                break;
            }
            // The reminder is delayed because the user was not logged in since more days then the first key of the delay array
            $reminder_is_delayed = true;
        }
        if ($dont_send_reminder) {
            // User was not logged in since too long
            return sprintf(T_('The user has not logged in for %d days, so we will not send him notifications any more'), $days_since_lastseen);
        }
        // Set reminder issue timestamp to x days after the last unread message notification date, where x is the delay from the configuration array
        $reminder_issue_ts = strtotime('+' . $delay . ' day', strtotime($last_unread_messages_reminder));
    }
    if ($reminder_issue_ts > $servertimenow) {
        // The next reminder issue date is in the future
        $time_left = seconds_to_period($reminder_issue_ts - $servertimenow);
        $info = sprintf(T_('%s left before next notification - sent by "Send reminders about unread messages" scheduled job'), $time_left);
    } else {
        // The next reminder issue date was in the past
        $time_since = seconds_to_period($servertimenow - $reminder_issue_ts);
        $info = sprintf(T_('next notification pending since %s - check the "Send reminders about unread messages" scheduled job'), $time_since);
    }
    if ($reminder_is_delayed) {
        // Reminder is delayed, add a note about this
        $note = sprintf(T_('The user has not logged in for %d days, so we will space out notifications by %d days.'), $days_since_lastseen, $delay);
    } elseif (empty($last_unread_messages_reminder)) {
        // The user didn't get unread messages reminder emails before
        $note = sprintf(T_('The user has never received a notification yet, so the first notification is sent with %s delay'), seconds_to_period($unread_messsage_reminder_threshold));
    } else {
        // Reminder is not delayed
        reset($unread_message_reminder_delay);
        $lasstseen_threshold = key($unread_message_reminder_delay);
        $delay = $unread_message_reminder_delay[$lasstseen_threshold];
        $note = sprintf(T_('The user has logged in in the last %d days, so we will space out notifications by %d days.'), $lasstseen_threshold, $delay);
    }
    return array($info, $note);
}
/**
 * This is sent to ((Moderators)) to remind them that some comments are still awaiting moderation 24 hours after they have been posted.
 *
 * For more info about email skins, see: http://b2evolution.net/man/themes-templates-skins/email-skins/
 *
 * b2evolution - {@link http://b2evolution.net/}
 * Released under GNU GPL License - {@link http://b2evolution.net/about/gnu-gpl-license}
 * @copyright (c)2003-2015 by Francois Planque - {@link http://fplanque.com/}
 */
if (!defined('EVO_MAIN_INIT')) {
    die('Please, do not access this page directly.');
}
// ---------------------------- EMAIL HEADER INCLUDED HERE ----------------------------
emailskin_include('_email_header.inc.txt.php', $params);
// ------------------------------- END OF EMAIL HEADER --------------------------------
global $admin_url, $baseurl, $htsrv_url, $comment_moderation_reminder_threshold;
$BlogCache =& get_BlogCache();
// Default params:
$params = array_merge(array('blogs' => array(), 'comments' => array()), $params);
echo sprintf(T_('There have been comments awaiting moderation for more than %s in the following blogs:'), seconds_to_period($comment_moderation_reminder_threshold));
echo "\n\n";
foreach ($params['blogs'] as $blog_ID) {
    $moderation_Blog = $BlogCache->get_by_ID($blog_ID);
    echo "\t - " . $moderation_Blog->get('shortname') . ' (' . sprintf(T_('%s comments waiting'), $params['comments'][$blog_ID]) . ') - ' . $admin_url . '?ctrl=dashboard&blog=' . $blog_ID . "\n";
}
// Footer vars:
$params['unsubscribe_text'] = T_('You are a moderator of this blog and you are receiving notifications when a comment may need moderation.') . "\n" . T_('If you don\'t want to receive any more notifications about comment moderation, click here') . ': ' . $htsrv_url . 'quick_unsubscribe.php?type=cmt_moderation_reminder&user_ID=$user_ID$&key=$unsubscribe_key$';
// ---------------------------- EMAIL FOOTER INCLUDED HERE ----------------------------
emailskin_include('_email_footer.inc.txt.php', $params);
// ------------------------------- END OF EMAIL FOOTER --------------------------------
Example #6
0
/**
 * Get account activation reminder informaton for the given user. This is used on the user admin settings form.
 *
 * @param $edited_User
 * @return array of arrays with field label, info and note about the Last and Next account activation emails
 */
function get_account_activation_info($edited_User)
{
    global $Settings, $UserSettings, $servertimenow, $activate_account_reminder_config;
    $field_label = T_('Latest account activation email');
    $can_be_validated = $edited_User->check_status('can_be_validated');
    if (!$can_be_validated) {
        if ($edited_User->check_status('is_validated')) {
            // The user account is already activated
            return array(array($field_label, T_('Account is already activated')));
        }
        if ($edited_User->check_status('is_closed')) {
            return array(array($field_label, T_('The account is closed, it cannot be activated')));
        }
        debug_die('Unhandled user account status!');
    }
    if (!$UserSettings->get('send_activation_reminder', $edited_User->ID)) {
        // The user doesn't want to receive account activation reminders
        return array(array($field_label, T_('This user doesn\'t want to receive account activation reminders')));
    }
    $field_note = '';
    $is_secure_validation = $Settings->get('validation_process') != 'easy';
    if ($is_secure_validation) {
        // The easy validation process is not allowed, so account activation emails are sent only for request
        $field_note = T_('Account validation process is secured, so account activation emails are sent only upon request');
    }
    $result = array();
    $last_activation_email = $UserSettings->get('last_activation_email', $edited_User->ID);
    if (empty($last_activation_email)) {
        // latest activation email date is not set because email was not sent yet ( it is possuble that there is some problem with the user email address )
        $result[] = array($field_label, T_('None yet'), $field_note);
    } else {
        // format last activation email date
        $last_activation_email_info = format_to_output($last_activation_email);
        $result[] = array($field_label, $last_activation_email_info, $field_note);
    }
    if ($is_secure_validation) {
        // When validation process is secure, then account activation email is not known, and this was already added as a note into the 'Last account activation email' field
        return $result;
    }
    $field_label = T_('Next account activation reminder');
    $number_of_max_reminders = count($activate_account_reminder_config) - 1;
    $activation_reminder_count = (int) $UserSettings->get('activation_reminder_count', $edited_User->ID);
    $field_note = sprintf(T_('%d reminders were sent out of the maximum allowed of %d.'), $activation_reminder_count, $number_of_max_reminders);
    // The validation process is easy, so reminders should be sent
    $responsible_job_note = T_('Scheduled job responsible for reminders is "Send reminders about not activated accounts".');
    if ($edited_User->status == 'failedactivation') {
        // The user account status was changed to failed activation, this user won't be reminded again to activate the account
        $result[] = array($field_label, T_('Account activation has failed'), $field_note . ' ' . $responsible_job_note);
    } elseif ($activation_reminder_count >= $number_of_max_reminders) {
        // This is the case when the account status was not changed to failed activation yet, but the last reminder was sent
        $result[] = array($field_label, sprintf(T_('We already sent %d account activation reminders of the maximum allowed of %d, no more reminders will be sent'), $activation_reminder_count, $number_of_max_reminders));
    } elseif (empty($last_activation_email)) {
        // Account activation email was not sent at all. This can happen when some problem is with the user email
        $result[] = array($field_label, T_('At least one activation email should have been already sent. Check if the user email address is correct, and PHP is sending emails correctly'), $responsible_job_note);
    } else {
        // Activate account reminder email should be send to the user, set information when it should be done
        $next_activation_email_ts = strtotime('+' . $activate_account_reminder_config[$activation_reminder_count] . ' second', strtotime($last_activation_email));
        if ($next_activation_email_ts > $servertimenow) {
            // The next activation email issue date is in the future
            $time_left = seconds_to_period($next_activation_email_ts - $servertimenow);
            $info = sprintf(T_('%s left before next notification') . ' - ' . $field_note, $time_left);
            $result[] = array($field_label, $info, $responsible_job_note);
        } else {
            // The next reminder issue date was in the past
            $time_since = seconds_to_period($servertimenow - $next_activation_email_ts);
            $info = sprintf(T_('next notification pending since %s - check the "Send reminders about not activated accounts" scheduled job'), $time_since);
            $result[] = array($field_label, $info, $field_note);
        }
    }
    return $result;
}
 *
 * For more info about email skins, see: http://b2evolution.net/man/themes-templates-skins/email-skins/
 *
 * b2evolution - {@link http://b2evolution.net/}
 * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
 * @copyright (c)2003-2013 by Francois Planque - {@link http://fplanque.com/}
 *
 * @version $Id: posts_unmoderated_reminder.html.php 3669 2013-05-06 06:59:42Z attila $
 */
if (!defined('EVO_MAIN_INIT')) {
    die('Please, do not access this page directly.');
}
// ---------------------------- EMAIL HEADER INCLUDED HERE ----------------------------
emailskin_include('_email_header.inc.html.php', $params);
// ------------------------------- END OF EMAIL HEADER --------------------------------
global $admin_url, $baseurl, $htsrv_url, $post_moderation_reminder_threshold;
$BlogCache =& get_BlogCache();
// Default params:
$params = array_merge(array('blogs' => array(), 'posts' => array()), $params);
echo '<p>' . sprintf(T_('There have been posts awaiting moderation for more than %s in the following blogs:'), seconds_to_period($post_moderation_reminder_threshold)) . '</p>';
echo '<ul>';
foreach ($params['blogs'] as $blog_ID) {
    $moderation_Blog = $BlogCache->get_by_ID($blog_ID);
    echo '<li>' . $moderation_Blog->get('shortname') . ' (' . sprintf(T_('%s posts waiting'), $params['posts'][$blog_ID]) . ') - ' . get_link_tag($admin_url . '?ctrl=dashboard&blog=' . $blog_ID, T_('Click here to moderate &raquo;')) . '</li>';
}
echo '</ul>';
// Footer vars:
$params['unsubscribe_text'] = T_('You are a moderator in this blog, and you are receiving notifications when the posts may need moderation.') . '<br />' . "\n" . T_('If you don\'t want to receive any more notifications about post moderation, click here:') . ' <a href="' . $htsrv_url . 'quick_unsubscribe.php?type=post_moderator&user_ID=$user_ID$&key=$unsubscribe_key$">' . T_('instant unsubscribe') . '</a>.';
// ---------------------------- EMAIL FOOTER INCLUDED HERE ----------------------------
emailskin_include('_email_footer.inc.html.php', $params);
// ------------------------------- END OF EMAIL FOOTER --------------------------------
if ($edited_User->check_perm('admin', 'restricted', false)) {
    // edited user has a permission to back-office
    $notify_options[] = array('edited_user_notify_meta_comments', 1, T_('a meta comment is posted.'), $UserSettings->get('notify_meta_comments', $edited_User->ID), $disabled);
}
if ($is_comment_moderator) {
    // edited user is comment moderator at least in one blog
    $notify_options[] = array('edited_user_send_cmt_moderation_reminder', 1, sprintf(T_('comments are awaiting moderation for more than %s.'), seconds_to_period($comment_moderation_reminder_threshold)), $UserSettings->get('send_cmt_moderation_reminder', $edited_User->ID), $disabled);
}
if ($edited_User->check_role('post_moderator')) {
    // edited user is post moderator at least in one blog
    $notify_options[] = array('edited_user_notify_post_moderation', 1, T_('a post is created and I have permissions to moderate it.'), $UserSettings->get('notify_post_moderation', $edited_User->ID), $disabled);
    $notify_options[] = array('edited_user_send_pst_moderation_reminder', 1, sprintf(T_('posts are awaiting moderation for more than %s.'), seconds_to_period($post_moderation_reminder_threshold)), $UserSettings->get('send_pst_moderation_reminder', $edited_User->ID), $disabled);
}
if ($current_User->check_perm('users', 'edit')) {
    // current User is an administrator
    $notify_options[] = array('edited_user_send_activation_reminder', 1, sprintf(T_('my account was deactivated or is not activated for more than %s.') . get_admin_badge('user'), seconds_to_period($activate_account_reminder_threshold)), $UserSettings->get('send_activation_reminder', $edited_User->ID));
}
if ($edited_User->check_perm('users', 'edit')) {
    // edited user has permission to edit all users, save notification preferences
    $notify_options[] = array('edited_user_notify_new_user_registration', 1, T_('a new user has registered.'), $UserSettings->get('notify_new_user_registration', $edited_User->ID), $disabled);
    $notify_options[] = array('edited_user_notify_activated_account', 1, T_('an account was activated.'), $UserSettings->get('notify_activated_account', $edited_User->ID), $disabled);
    $notify_options[] = array('edited_user_notify_closed_account', 1, T_('an account was closed.'), $UserSettings->get('notify_closed_account', $edited_User->ID), $disabled);
    $notify_options[] = array('edited_user_notify_reported_account', 1, T_('an account was reported.'), $UserSettings->get('notify_reported_account', $edited_User->ID), $disabled);
    $notify_options[] = array('edited_user_notify_changed_account', 1, T_('an account was changed.'), $UserSettings->get('notify_changed_account', $edited_User->ID), $disabled);
}
if ($edited_User->check_perm('options', 'edit')) {
    // edited user has permission to edit options, save notification preferences
    $notify_options[] = array('edited_user_notify_cronjob_error', 1, T_('a scheduled task ends with an error or timeout.'), $UserSettings->get('notify_cronjob_error', $edited_User->ID), $disabled);
}
if (!empty($notify_options)) {
    $Form->checklist($notify_options, 'edited_user_notification', T_('Notify me by email whenever'), false, false, $checklist_params);
/**
 * This is sent to ((Moderators)) to remind them that some comments are still awaiting moderation 24 hours after they have been posted.
 *
 * For more info about email skins, see: http://b2evolution.net/man/themes-templates-skins/email-skins/
 *
 * b2evolution - {@link http://b2evolution.net/}
 * Released under GNU GPL License - {@link http://b2evolution.net/about/gnu-gpl-license}
 * @copyright (c)2003-2015 by Francois Planque - {@link http://fplanque.com/}
 */
if (!defined('EVO_MAIN_INIT')) {
    die('Please, do not access this page directly.');
}
// ---------------------------- EMAIL HEADER INCLUDED HERE ----------------------------
emailskin_include('_email_header.inc.html.php', $params);
// ------------------------------- END OF EMAIL HEADER --------------------------------
global $admin_url, $baseurl, $htsrv_url, $comment_moderation_reminder_threshold;
$BlogCache =& get_BlogCache();
// Default params:
$params = array_merge(array('blogs' => array(), 'comments' => array()), $params);
echo '<p' . emailskin_style('.p') . '>' . sprintf(T_('There have been comments awaiting moderation for more than %s in the following blogs:'), seconds_to_period($comment_moderation_reminder_threshold)) . '</p>';
echo '<ul>';
foreach ($params['blogs'] as $blog_ID) {
    $moderation_Blog = $BlogCache->get_by_ID($blog_ID);
    echo '<li>' . $moderation_Blog->get('shortname') . ' (' . sprintf(T_('%s comments waiting'), $params['comments'][$blog_ID]) . ') - ' . get_link_tag($admin_url . '?ctrl=dashboard&blog=' . $blog_ID, T_('Click here to moderate') . ' &raquo;', '.a') . '</li>';
}
echo '</ul>';
// Footer vars:
$params['unsubscribe_text'] = T_('You are a moderator of this blog and you are receiving notifications when a comment may need moderation.') . '<br />' . "\n" . T_('If you don\'t want to receive any more notifications about comment moderation, click here') . ': ' . '<a href="' . $htsrv_url . 'quick_unsubscribe.php?type=cmt_moderation_reminder&user_ID=$user_ID$&key=$unsubscribe_key$"' . emailskin_style('.a') . '>' . T_('instant unsubscribe') . '</a>.';
// ---------------------------- EMAIL FOOTER INCLUDED HERE ----------------------------
emailskin_include('_email_footer.inc.html.php', $params);
// ------------------------------- END OF EMAIL FOOTER --------------------------------