Author Topic: Private Nachrichten / private messages  (Read 8122 times)

0 Members and 1 Guest are viewing this topic.

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.805
  • I ♥ 4I
    • View Profile
Private Nachrichten / private messages
« on: October 16, 2011, 04:47:24 PM »
Hallo zusammen,

ich habe in der logininfo einen Link zu den Privaten Nachrichten im Woltlab Burning Board. (forum/index.php?page=PMList)
Ich möchte aber bei erhalt einer Nachricht, hinter dem Link auch eine 1 oder andere Zahl steht.
Dazu muss man die Datenbank passend auslesen. Ich muss auf wcf1_user zugreifen und pmOutstandingNotifications auslesen. Das was dort steht ist die Anzahl der noch ungelesenen Nachrichten.
Mein Link sieht so aus:
Code: [Select]
<a href="forum/index.php?page=PMList">Private Nachrichten</a>Wenn jetzt nun neue Nachrichten vorhanden sind, soll der Link demnach so aussehen:
Code: [Select]
<a href="forum/index.php?page=PMList"><strong>Private Nachrichten (3)</strong></a>Hat dafür jemand eine Idee?

--

Hi all,

I have the login info in a link to the private messaging in WoltLab Burning Board. (forum/index.php?page=PMList)
But I want to sustaining a message behind the link is also a 1 or a different number.
This requires you to read the database appropriately. I need to access and wcf1_user pmOutstandingNotifications read. That what it says is the number of unread messages.
My link looks like this:
Code: [Select]
<a href="forum/index.php?page=PMList">Private Messages</ a>Now, if now there are new messages, the link should therefore look like this:
Code: [Select]
<a href="forum/index.php?page=PMList"><strong>Private Messages (3)</ strong></ a>Does anyone have an idea for it?

includes/page_header.php
Above / Über:
$site_template->register_vars(array(
  
"home_url"  => ROOT_PATH,
  
"media_url" => MEDIA_PATH,

This / Das ?
$sql "SELECT w.pmOutstandingNotifications
        FROM ("
.USERS_TABLE." u)
	
	
LEFT JOIN wcf1_user w ON (w.userID = "
.get_user_table_field("u.""user_id").")
        WHERE u.user_id = 
$user_id";
$wbb_row $site_db->query_firstrow($sql);

Die User haben in beide Systeme die gleiche ID / The users have the same ID in both systems

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Private Nachrichten / private messages
« Reply #1 on: October 16, 2011, 05:36:22 PM »
I'm lost, it doesn't work or what?
do you get the correct number in $wbb_row['pmOutstandingNotifications'] ?
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.805
  • I ♥ 4I
    • View Profile
Re: Private Nachrichten / private messages
« Reply #2 on: October 16, 2011, 08:06:22 PM »
Quote
Hi Vano,

in the database query I get this error:

Quote
DB Error: Bad SQL Query: SELECT w.pmOutstandingNotifications FROM (4images_users u) LEFT JOIN wcf1_user w ON (w.userID = u.user_id) WHERE u.user_id =
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 '' at line 4

My steps:
1) includes/page_header.php
search:
$site_template->register_vars(array(
  
"home_url"  => ROOT_PATH,
  
"media_url" => MEDIA_PATH,

add before:
$sql "SELECT w.pmOutstandingNotifications
        FROM ("
.USERS_TABLE." u)
        LEFT JOIN wcf1_user w ON (w.userID = "
.get_user_table_field("u.""user_id").")
        WHERE u.user_id = 
$user_id";
$wbb_row $site_db->query_firstrow($sql);

Search:
"media_url" => MEDIA_PATH,
add after:
"user_pm" => $wbb_row['pmOutstandingNotifications'],

And I use the variable in the details.html
{user_pm}

BUT
If I use the database query to
$sql "SELECT w.pmOutstandingNotifications
        FROM ("
.USERS_TABLE." u)
        LEFT JOIN wcf1_user w ON (w.userID = "
.get_user_table_field("u.""user_id").")
        WHERE u.user_id = "
.$user_info['user_id']."";
$wbb_row $site_db->query_firstrow($sql);


Then work das. The issue of {user_p}" is also correct

Now the question arises how the link will change automatically.
The best would be the query with an if and endif

{if user_pm}
<a href="forum/index.php?page=PMList"><strong>Private Messages (THE NUMBER OF PMs)</strong></a>
{endif user_pm}
{ifno user_pm}
<a href="forum/index.php?page=PMList"><strong>Private Messages</strong></a>
{endifno user_pm}

Update with questions
I have now constructed the following:

1) includes/page_header.php
Find:
$site_template->register_vars(array(
  
"home_url"  => ROOT_PATH,
  
"media_url" => MEDIA_PATH,

Previously inserted
$sql "SELECT w.pmOutstandingNotifications
        FROM ("
.USERS_TABLE." u)
        LEFT JOIN wcf1_user w ON (w.userID = "
.get_user_table_field("u.""user_id").")
        WHERE u.user_id = "
.$user_info['user_id']."";
$wbb_row $site_db->query_firstrow($sql);


  if (!empty(
$wbb_row['pmOutstandingNotifications'])) {
	
$user_pm '<li class="new" id="userMenuPm"><a href="forum/index.php?page=PMList"><img src="forum/wcf/icon/pmEmptyS.png" alt="" /> <span>Private Nachrichten ('.$wbb_row['pmOutstandingNotifications'].')</span></a></li>';
  }
  else {
    
$user_pm '<li id="userMenuPm"><a href="forum/index.php?page=PMList"><img src="forum/wcf/icon/pmEmptyS.png" alt="" /> <span>Private Nachrichten</span></a></li>';
  }

and then
"user_pm" => $user_pm,
It works like everything. I can now spend with {user_pm} status
But how can I use the if and endif details page? I need to make a status indication

{if user_pm}<div class="info">You have {user_pm} Messages</div>{endif user_pm} ??

Update 2:
$user_pm_info = !empty($wbb_row['pmOutstandingNotifications']) ? '<div class="info">Test</div>' '';
"user_pm_info" => $user_pm_info,
Works for Status Message

And the most important question. Is that correct, if all that stands in the page_header.php? If yes, at this point?
« Last Edit: October 16, 2011, 09:34:02 PM by Sumale.nin »

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
Re: Private Nachrichten / private messages
« Reply #3 on: October 16, 2011, 10:18:57 PM »
That looks ok to me, there is some room for optimization, but it will work just fine.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline Sunny C.

  • Addicted member
  • ******
  • Posts: 1.805
  • I ♥ 4I
    • View Profile
Re: Private Nachrichten / private messages
« Reply #4 on: October 17, 2011, 09:55:30 AM »
Ok, thx!