Skip to Content Skip to Menu

🌟Discover the Joomla AI Plugin that wrote its own story! - CB Editor Assistant 1.1now for Joomla 3, 4 & 5!
✍️ 5-Day Free Trial, then 🎯 save up to 30% with our 🛍️ Intro Offer (First 50 users, ends Dec. 25th)
🌲 Merry Christmas! Great savings on Professional and Developer Memberships! Get 25% off now with code XMAS-2024!

PMS Questions

  • Deciman
  • Deciman
  • OFFLINE
  • Posts: 4
  • Thanks: 0
  • Karma: 0
1 year 2 months ago #335341 by Deciman
PMS Questions was created by Deciman
Hi there

Is there any way to read the number of
'unread' messages (inbox)
and maybe even 'unread by receiver' messages (outbox)
from an external php script?

Reason:
I use a selfmade script to create/modify the menu of our website
and I want do manipulate the output for the 'Messages' item inside this menu (permanently present after login)
to show the number of 'unread' or 'unreceived' messages.
Manipulating the content of the button itself is not the problem.
But how can I let read the needed data from the loged-in-users mailbox?

Deci

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48616
  • Thanks: 8302
  • Karma: 1446
1 year 2 months ago #335342 by krileon
Replied by krileon on topic PMS Questions
If you're modifying with a script that's executed within Joomla so it has access to Joomla API then it's easy enough to just call CBs API to get the unread count. Ideally you should be using a Joomla plugin acting on Joomla menu events to modify the menu which would allow for this. Otherwise your only option is to establish a database connection and query for the unread count. Below is the query being used internally.
Code:
public function getPMSunreadCount( $userId ) { global $_CB_database; if ( UddeIM::isUddeIM() ) { return UddeIM::getPMSunreadCount( $userId ); } static $cache = array(); if ( ! isset( $cache[$userId] ) ) { $query = "SELECT COUNT(*)" . "\n FROM " . $_CB_database->NameQuote( '#__comprofiler_plugin_messages' ) . " AS m" . "\n LEFT JOIN " . $_CB_database->NameQuote( '#__comprofiler_plugin_messages_read' ) . " AS r" . " ON r." . $_CB_database->NameQuote( 'to_user' ) . " = " . (int) $userId . " AND r." . $_CB_database->NameQuote( 'message' ) . " = m." . $_CB_database->NameQuote( 'id' ) . "\n WHERE ( ( m." . $_CB_database->NameQuote( 'from_user' ) . " != " . (int) $userId . " AND m." . $_CB_database->NameQuote( 'to_user' ) . " = 0 )" . " OR ( m." . $_CB_database->NameQuote( 'to_user' ) . " = " . (int) $userId . " AND m." . $_CB_database->NameQuote( 'to_user_delete' ) . " = 0 ) )" . "\n AND r." . $_CB_database->NameQuote( 'id' ) . " IS NULL"; $_CB_database->setQuery( $query ); $cache[$userId] = (int) $_CB_database->loadResult(); } return $cache[$userId]; }

That's just the PHP function for it. You'll need to extract the SQL out for your needs from this.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • Deciman
  • Deciman
  • OFFLINE
  • Posts: 4
  • Thanks: 0
  • Karma: 0
1 year 2 months ago #335344 by Deciman
Replied by Deciman on topic PMS Questions
Thanks

I'll check if (and how) I can use that within my scripts...
But I guess it will be not easy...

Forgot to mention:
The 'manipulation' of the output (creating menue items/showing/hiding them according to the screen width)
is done by a custom java script implemented inside the template...


Deci
 

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48616
  • Thanks: 8302
  • Karma: 1446
1 year 2 months ago #335347 by krileon
Replied by krileon on topic PMS Questions
If this is entirely JavaScript then you of course can't get the PMS count. You need to be able to communicate with the server for that information. I guess you could have it displayed in your login module then use JS to pull it out of your login module to display it elsewhere. That'd be the only thing I could suggest. You can enable the PMS count in your CB login module settings.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in or Create an account to join the conversation.

  • Deciman
  • Deciman
  • OFFLINE
  • Posts: 4
  • Thanks: 0
  • Karma: 0
1 year 2 months ago - 1 year 2 months ago #335349 by Deciman
Replied by Deciman on topic PMS Questions
That's what I supposed.
But having a script (php) inside joomla gives me the possibility to write the needed data somehow and somewhere on the webside.
And once it is written there I can read it by java script...

Deci

PS: Using the login module is not really an option
as the users have the ability (and use it) to log in automatically ...
But once logged in (and that is when my script gets active, because the 'messages' menu item is only active for logged in users)
there should be enough further options (plugin) to read and write the needed data
Last edit: 1 year 2 months ago by Deciman.

Please Log in or Create an account to join the conversation.

  • Deciman
  • Deciman
  • OFFLINE
  • Posts: 4
  • Thanks: 0
  • Karma: 0
1 year 2 months ago #335364 by Deciman
Replied by Deciman on topic PMS Questions
Is working...

Created a Module writing the needed content on the webside.
Extended my java script to read that content
and manipulate the menu item to show new messages (if existing) as a second row in the text

Tnx

Please Log in or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum