Support Forum

Advanced Search
Forum Scope


Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
themes-topic
Changing Inbox Button Color If Unread Messages
Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Dec 9, 2018 - 9:38 pm

Jim, 

your code still should work... just need to adjust how you get the current user id...  try changing:

$spThisUser->ID

to be

SP()->user->thisUser->user_id

everything is class based now instead of bunch of globals...

Avatar
jim
Here and Now
Member
Pro Subscribers
sp_UserOfflineSmall Offline
Dec 9, 2018 - 11:29 pm

Mr Papa said
try changing...

Perfect, that did the trick. Thank you for the prompt response!

Just in case anyone is looking for help with this same issue, here's the complete edit:

spHeadDesktop.php:111

# start reboot unread pm hack
if (function_exists('sp_PmInboxButton')) {
$newPM = sp_pm_get_inbox_unread_count(SP()->user->thisUser->user_id);
$icon = ($newPM > 0) ? 'sp_PmInboxButtonUnread.png' : 'sp_PmInboxButton.png';
$class = ($newPM > 0) ? 'spButtonUnread' : 'spButton';
sp_PmInboxButton("tagClass=$class spRight&icon=$icon", __sp('Inbox:'), __sp('Go to PM inbox'));
}
# end reboot pm hack

TripawdsSimple:Press powers the Tripawds Discussion Forums.

It's better to hop on three legs than to limp on four.

The Tripawds Blogs Community is made possible by The Tripawds Foundation.

Avatar
jim
Here and Now
Member
Pro Subscribers
sp_UserOfflineSmall Offline
Dec 10, 2018 - 2:43 pm

Sigh...

So I just discovered this issue persists for any user not logged in.

The hack above works fine when the user is logged in, all pages load fine with no error.

Invalid Database Query error occurs on all forum pages for any user not logged in.

From the SP Error Log:

December 10, 2018 12:36 pm | spaErrError | 60 | database


file: .../public_html/wp-content/sp-resources/forum-plugins/private-messaging/library/sp-pm-database.php
line: 114
function: count
error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND read_status=0' at line 1

TripawdsSimple:Press powers the Tripawds Discussion Forums.

It's better to hop on three legs than to limp on four.

The Tripawds Blogs Community is made possible by The Tripawds Foundation.

Avatar
jim
Here and Now
Member
Pro Subscribers
sp_UserOfflineSmall Offline
Dec 10, 2018 - 2:44 pm

Unable to post entire log entry including query here...

Screen-Shot-2018-12-10-at-11.43.29-AM.pngImage Enlarger

TripawdsSimple:Press powers the Tripawds Discussion Forums.

It's better to hop on three legs than to limp on four.

The Tripawds Blogs Community is made possible by The Tripawds Foundation.

Avatar
jim
Here and Now
Member
Pro Subscribers
sp_UserOfflineSmall Offline
Dec 10, 2018 - 8:09 pm

So, I figure the invalid db query error must have something to do with this:

$newPM = sp_pm_get_inbox_unread_count(SP()->user->thisUser->user_id);

Because if users are not logged in, they they have no ID. Right?

The previous use of "globals" @mr-papa mentioned must have addressed this, because we never experienced it before. Is there some class used to identify guests that can be applied in this scenario?

TripawdsSimple:Press powers the Tripawds Discussion Forums.

It's better to hop on three legs than to limp on four.

The Tripawds Blogs Community is made possible by The Tripawds Foundation.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Dec 10, 2018 - 9:15 pm

No, that is incorrect... they will have a ID of 0 for guests...  but does look like I gave you incorrect code... should be:

SP()->user->thisUser->ID

but I will have to research why the member user_id even exists for users... and why we use it in couple locations...  should be consistent and stick with the right one..

Avatar
jim
Here and Now
Member
Pro Subscribers
sp_UserOfflineSmall Offline
Dec 10, 2018 - 11:12 pm

Mr Papa said
but does look like I gave you incorrect code...

Fantastic! Thanks for the quick fix, as usual. I can confirm that does the trick.

Just one more issue to resolve and we can update our live site to SP 6.0.

TripawdsSimple:Press powers the Tripawds Discussion Forums.

It's better to hop on three legs than to limp on four.

The Tripawds Blogs Community is made possible by The Tripawds Foundation.

Avatar
Mr Papa
Simi Valley, CA
SP Master
Free Members
sp_UserOfflineSmall Offline
Dec 12, 2018 - 9:18 pm

glad its fixed!

Forum Timezone: Europe/Stockholm
Most Users Ever Online: 1170
Currently Online:
Guest(s) 1
Currently Browsing this Page:
1 Guest(s)
Top Posters:
Mr Papa: 19448
Ike: 2086
Brandon: 864
kvr28: 804
jim: 650
FidoSysop: 577
Conrad_Farlow: 531
fiddlerman: 358
Stefano Prete: 325
Member Stats:
Guest Posters: 619
Members: 17364
Moderators: 0
Admins: 4
Forum Stats:
Groups: 7
Forums: 17
Topics: 10127
Posts: 79625