4images Forum & Community

General / Allgemeines => Programming => Topic started by: Sunny C. on October 16, 2011, 04:47:24 PM

Title: Private Nachrichten / private messages
Post by: Sunny C. 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
Title: Re: Private Nachrichten / private messages
Post by: V@no 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'] ?
Title: Re: Private Nachrichten / private messages
Post by: Sunny C. 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?
Title: Re: Private Nachrichten / private messages
Post by: V@no 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.
Title: Re: Private Nachrichten / private messages
Post by: Sunny C. on October 17, 2011, 09:55:30 AM
Ok, thx!