PHPFusion\PrivateMessages::get_pm_settings PHP Method

get_pm_settings() public static method

public static get_pm_settings ( $user_id, $key = NULL )
    public static function get_pm_settings($user_id, $key = NULL)
    {
        if (iMEMBER) {
            global $userdata;
            // make sure they have it when registering
            $settings = array("user_inbox" => fusion_get_settings("pm_inbox_limit"), "user_outbox" => fusion_get_settings("pm_outbox_limit"), "user_archive" => fusion_get_settings("pm_archive_limit"), "user_pm_email_notify" => fusion_get_settings("pm_email_notify"), "user_pm_save_sent" => fusion_get_settings("pm_save_sent"));
            if ($user_id !== $userdata) {
                $result = dbquery("\n\t\t\tSELECT user_inbox, user_outbox, user_archive, user_pm_email_notify, user_pm_save_sent\n\t\t\tFROM " . DB_USERS . " WHERE user_id='" . intval($user_id) . "' and user_status = '0'\n\t\t\t");
                if (dbrows($result) > 0) {
                    $data = dbarray($result);
                    // What this does is that if any of the params is 0, we use default system values.
                    $settings = array("user_inbox" => !empty($data['user_inbox']) ? intval($data['user_inbox']) : intval($settings['user_inbox']), "user_outbox" => !empty($data['user_outbox']) ? intval($data['user_outbox']) : intval($settings['user_outbox']), "user_archive" => !empty($data['user_archive']) ? intval($data['user_archive']) : intval($settings['user_archive']), "user_pm_email_notify" => !empty($data['user_pm_email_notify']) ? intval($data['user_pm_email_notify']) : intval($settings['user_pm_email_notify']), "user_pm_save_sent" => !empty($data['user_pm_save_sent']) ? intval($data['user_pm_save_sent']) : intval($settings['user_pm_save_sent']));
                }
            } else {
                $settings = array("user_inbox" => $userdata['user_inbox'], "user_outbox" => $userdata['user_outbox'], "user_archive" => $userdata['user_archive'], "user_pm_email_notify" => $userdata['user_pm_email_notify'], "user_pm_save_sent" => $userdata['user_pm_save_sent']);
            }
            if (iADMIN || iSUPERADMIN) {
                $settings['user_inbox'] = 0;
                $settings['user_outbox'] = 0;
                $settings['user_archive'] = 0;
            }
            return $key === NULL ? $settings : (isset($settings[$key]) ? $settings[$key] : NULL);
        }
        return NULL;
    }

Usage Example

/**
 * Fetch PM Settings
 * @param      $user_id
 * @param null $key - user_inbox, user_outbox, user_archive, user_pm_email_notify, user_pm_save_sent
 * @return array|bool|null
 */
function user_pm_settings($user_id, $key = NULL)
{
    return \PHPFusion\PrivateMessages::get_pm_settings($user_id, $key);
}