Beispiel #1
0
function light_pm_check_messages()
{
    // Check if this function has be called multiple times in one request.
    static $light_pm_check_messages_done = false;
    // Check if we've already displayed the notification once.
    if ($light_pm_check_messages_done === true) {
        return;
    }
    // Get the webtag
    $webtag = get_webtag();
    forum_check_webtag_available($webtag);
    // Default the variables to return 0 even on error.
    $new_count = 0;
    $outbox_count = 0;
    $unread_count = 0;
    // Get the number of messages.
    pm_get_message_count($new_count, $outbox_count, $unread_count);
    // Format the message sent to the client.
    if ($new_count == 1 && $outbox_count == 0) {
        $notification = gettext("You have 1 new message. Would you like to go to your Inbox now?");
    } else {
        if ($new_count == 1 && $outbox_count == 1) {
            $notification = gettext("You have 1 new message.\n\nYou also have 1 message awaiting delivery. To receive this message please clear some space in your Inbox.\n\nWould you like to go to your Inbox now?");
        } else {
            if ($new_count == 0 && $outbox_count == 1) {
                $notification = gettext("You have 1 message awaiting delivery. To receive this message please clear some space in your Inbox.\n\nWould you like to go to your Inbox now?");
            } else {
                if ($new_count > 1 && $outbox_count == 0) {
                    $notification = sprintf(gettext("You have %d new messages. Would you like to go to your Inbox now?"), $new_count);
                } else {
                    if ($new_count > 1 && $outbox_count == 1) {
                        $notification = sprintf(gettext("You have %d new messages.\n\nYou also have 1 message awaiting delivery. To receive this message please clear some space in your Inbox.\n\nWould you like to go to your Inbox now?"), $new_count);
                    } else {
                        if ($new_count > 1 && $outbox_count > 1) {
                            $notification = sprintf(gettext("You have %d new messages.\n\nYou also have %d messages awaiting delivery. To receive these message please clear some space in your Inbox.\n\nWould you like to go to your Inbox now?"), $new_count, $outbox_count);
                        } else {
                            if ($new_count == 1 && $outbox_count > 1) {
                                $notification = sprintf(gettext("You have 1 new message.\n\nYou also have %d messages awaiting delivery. To receive these messages please clear some space in your Inbox.\n\nWould you like to go to your Inbox now?"), $outbox_count);
                            } else {
                                if ($new_count == 0 && $outbox_count > 1) {
                                    $notification = sprintf(gettext("You have %d messages awaiting delivery. To receive these messages please clear some space in your Inbox.\n\nWould you like to go to your Inbox now?"), $outbox_count);
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    if (isset($notification) && strlen(trim($notification)) > 0) {
        // Wrap the notification in a hyperlink.
        $notification = sprintf("<a href=\"lpm.php?webtag={$webtag}\">%s</a>\n", $notification);
        // Display the notification
        light_html_display_success_msg($notification);
    }
    // Prevent checking again.
    $light_pm_check_messages_done = true;
}
Beispiel #2
0
require_once BH_INCLUDE_PATH . 'pm.inc.php';
require_once BH_INCLUDE_PATH . 'search.inc.php';
require_once BH_INCLUDE_PATH . 'session.inc.php';
require_once BH_INCLUDE_PATH . 'word_filter.inc.php';
// End Required includes
// Check we're logged in correctly
if (!session::logged_in()) {
    html_guest_error();
}
// Check that PM system is enabled
pm_enabled();
$new_count = 0;
$outbox_count = 0;
$unread_count = 0;
$current_folder = PM_FOLDER_INBOX;
pm_get_message_count($new_count, $outbox_count, $unread_count);
$error_msg_array = array();
if (!($folder_names_array = pm_get_folder_names())) {
    $folder_names_array = array(PM_FOLDER_INBOX => gettext("Inbox"), PM_FOLDER_SENT => gettext("Sent Items"), PM_FOLDER_OUTBOX => gettext("Outbox"), PM_FOLDER_SAVED => gettext("Saved Items"), PM_FOLDER_DRAFTS => gettext("Drafts"), PM_SEARCH_RESULTS => gettext("Search Results"));
}
if (isset($_GET['sort_by'])) {
    if ($_GET['sort_by'] == "SUBJECT") {
        $sort_by = "PM.SUBJECT";
    } else {
        if ($_GET['sort_by'] == "TYPE") {
            $sort_by = "TYPE";
        } else {
            if ($_GET['sort_by'] == "FROM_UID") {
                $sort_by = "PM.FROM_UID";
            } else {
                if ($_GET['sort_by'] == "TO_UID") {
require_once BH_INCLUDE_PATH . 'post.inc.php';
require_once BH_INCLUDE_PATH . 'search.inc.php';
require_once BH_INCLUDE_PATH . 'session.inc.php';
require_once BH_INCLUDE_PATH . 'user.inc.php';
require_once BH_INCLUDE_PATH . 'word_filter.inc.php';
require_once BH_INCLUDE_PATH . 'zip_lib.inc.php';
// Check we're logged in correctly
if (!session::logged_in()) {
    html_guest_error();
}
// Check that PM system is enabled
pm_enabled();
$pm_new_count = 0;
$pm_outbox_count = 0;
$pm_unread_count = 0;
pm_get_message_count($pm_new_count, $pm_outbox_count, $pm_unread_count);
$uid = session::get_value('UID');
$error_msg_array = array();
if (!($pm_folder_names_array = pm_get_folder_names())) {
    $pm_folder_names_array = array(PM_FOLDER_INBOX => gettext("Inbox"), PM_FOLDER_SENT => gettext("Sent Items"), PM_FOLDER_OUTBOX => gettext("Outbox"), PM_FOLDER_SAVED => gettext("Saved Items"), PM_FOLDER_DRAFTS => gettext("Drafts"), PM_SEARCH_RESULTS => gettext("Search Results"));
}
$pm_folder_name_array = array(PM_OUTBOX => $pm_folder_names_array[PM_FOLDER_OUTBOX], PM_UNREAD => $pm_folder_names_array[PM_FOLDER_INBOX], PM_READ => $pm_folder_names_array[PM_FOLDER_INBOX], PM_SENT => $pm_folder_names_array[PM_FOLDER_SENT], PM_SAVED_IN => $pm_folder_names_array[PM_FOLDER_SAVED], PM_SAVED_OUT => $pm_folder_names_array[PM_FOLDER_SAVED], PM_SAVED_DRAFT => $pm_folder_names_array[PM_FOLDER_DRAFTS]);
if (isset($_GET['sort_by'])) {
    if ($_GET['sort_by'] == "SUBJECT") {
        $sort_by = "PM.SUBJECT";
    } else {
        if ($_GET['sort_by'] == "TYPE") {
            $sort_by = "TYPE";
        } else {
            if ($_GET['sort_by'] == "FROM_UID") {
                $sort_by = "PM.FROM_UID";
Beispiel #4
0
function pm_check_messages()
{
    // Get the number of messages.
    pm_get_message_count($pm_new_count, $pm_outbox_count, $pm_unread_count);
    // Disabled for Guests
    if (!session::logged_in()) {
        return false;
    }
    // Check if the user wants Javascript notifcation.
    if (isset($_SESSION['PM_NOTIFY']) && $_SESSION['PM_NOTIFY'] == 'Y') {
        // Format the message sent to the client.
        if ($pm_new_count == 1 && $pm_outbox_count == 0) {
            $pm_notification = gettext("You have 1 new message. Would you like to go to your Inbox now?");
        } else {
            if ($pm_new_count == 1 && $pm_outbox_count == 1) {
                $pm_notification = gettext("You have 1 new message.\n\nYou also have 1 message awaiting delivery. To receive this message please clear some space in your Inbox.\n\nWould you like to go to your Inbox now?");
            } else {
                if ($pm_new_count == 0 && $pm_outbox_count == 1) {
                    $pm_notification = gettext("You have 1 message awaiting delivery. To receive this message please clear some space in your Inbox.\n\nWould you like to go to your Inbox now?");
                } else {
                    if ($pm_new_count > 1 && $pm_outbox_count == 0) {
                        $pm_notification = sprintf(gettext("You have %d new messages. Would you like to go to your Inbox now?"), $pm_new_count);
                    } else {
                        if ($pm_new_count > 1 && $pm_outbox_count == 1) {
                            $pm_notification = sprintf(gettext("You have %d new messages.\n\nYou also have 1 message awaiting delivery. To receive this message please clear some space in your Inbox.\n\nWould you like to go to your Inbox now?"), $pm_new_count);
                        } else {
                            if ($pm_new_count > 1 && $pm_outbox_count > 1) {
                                $pm_notification = sprintf(gettext("You have %d new messages.\n\nYou also have %d messages awaiting delivery. To receive these message please clear some space in your Inbox.\n\nWould you like to go to your Inbox now?"), $pm_new_count, $pm_outbox_count);
                            } else {
                                if ($pm_new_count == 1 && $pm_outbox_count > 1) {
                                    $pm_notification = sprintf(gettext("You have 1 new message.\n\nYou also have %d messages awaiting delivery. To receive these messages please clear some space in your Inbox.\n\nWould you like to go to your Inbox now?"), $pm_outbox_count);
                                } else {
                                    if ($pm_new_count == 0 && $pm_outbox_count > 1) {
                                        $pm_notification = sprintf(gettext("You have %d messages awaiting delivery. To receive these messages please clear some space in your Inbox.\n\nWould you like to go to your Inbox now?"), $pm_outbox_count);
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    $pm_notification_data = array();
    if ($pm_new_count > 0) {
        $pm_notification_data['text'] = sprintf('[%d %s]', $pm_new_count, gettext("New"));
    } else {
        if ($pm_unread_count > 0) {
            $pm_notification_data['text'] = sprintf('[%d %s]', $pm_unread_count, gettext("Unread"));
        }
    }
    if (isset($pm_notification) && strlen(trim($pm_notification)) > 0) {
        $pm_notification_data['notification'] = wordwrap($pm_notification, 65, "\n");
    }
    return $pm_notification_data;
}