PDA

View Full Version : Last PM on Forumhome


Kratheous
19 Jan 2003, 21:44
This hack will show you last PM you recieved on the forumhome.

Kratheous
19 Jan 2003, 22:00
Screenshot:

Disturbed
20 Jan 2003, 04:13
nice, thanks for sharing ^^

Sebastian
20 Jan 2003, 08:59
it doen't work for me.. no errors, just says i have no new pms when i do. v229

Floris
20 Jan 2003, 08:59
Great, I will install it right away, nice little hack! simple/easy/effective :)

Floris
20 Jan 2003, 09:05
floris - You have 1 new message(s) since your last visit.
(You have 1 unread messages and 42 total messages in all your folders.)
You have no Private Messages in your inbox at the moment.

Uhm, doesn't seem to be working though :> vB 2.2.9

Floris
20 Jan 2003, 09:16
inph from the irc informed me to also add the templates that are used into the $templatesused=' bit.

So, find:

$templatesused=' (in the top of index.php)

and at the end of the line, replace:
';
with:
,forumhome_pmlastno,forumhome_pmlast';

Boofo
20 Jan 2003, 09:37
Well, it works for me, almost. It says the last message title correct but is has ARRAY as the user the message is from (and there is no such user on my board). Also, the message it is picking up was moved out of the Inbox into another folder. Is it supposed to show only pms in your inbox?

inphinity
20 Jan 2003, 09:48
i think $lastpmuser should be referenced as:
<br><br><b>Latest Private Message:</b> $lastpmstuff[title] by $lastpmuser['username']

also it is the last pm recieved in all folders

you could limit it to inbox by adding folderid = 0 after WHERE in the $lastpmstuff query

Boofo
20 Jan 2003, 10:06
Should it look like this?

$lastpmstuff=$DB_site->query_first("SELECT * FROM privatemessage WHERE folderid = 0 userid=$bbuserinfo[userid] and fromuserid!=$bbuserinfo[userid] $ignoreusers ORDER BY dateline DESC LIMIT 1");

inphinity
20 Jan 2003, 10:36
put an 'and' in there as well

folderid = 0 AND userid=$bbuserinfo[userid]

Boofo
20 Jan 2003, 10:41
Thank you very much. ;) Would there also be a way to pull out the name of the folder the message is in, too?

inphinity
20 Jan 2003, 11:46
if ($bbuserinfo[pmfolders]) {
$allfolders = explode("\n", trim($bbuserinfo[pmfolders]));
while (list($key,$val)=each($allfolders)) {
$thisfolder = explode("|||", $val);
}
}

$thisfolder[$folderid] = name of folder message is in
$thisfolder[0] (inbox) has a name of "1"

pm folder names are kept in the user table

Boofo
20 Jan 2003, 11:57
Originally posted by inphinity
if ($bbuserinfo[pmfolders]) {
$allfolders = explode("\n", trim($bbuserinfo[pmfolders]));
while (list($key,$val)=each($allfolders)) {
$thisfolder = explode("|||", $val);
}
}

$thisfolder[$folderid] = name of folder message is in
$thisfolder[0] (inbox) has a name of "1"

pm folder names are kept in the user table

I kind of follow you on this. I put the first 6 lines in but I got lost with the last two lines. :) What would be the complete code I need to do it?

mauce
20 Jan 2003, 12:36
So how would the hack look like in total?
I'm kinda confused now.

Corrupter
21 Jan 2003, 08:00
Mine is showing last PM by ARRAY..

Do you have the correct code for this?

Corrupter
21 Jan 2003, 08:06
Nevermind..

The correct code for template: forumhome_pmlast

<br><b>Latest Private Message:</b> $lastpmstuff[title] by $lastpmuser[username]

See Image:

Kratheous
21 Jan 2003, 16:01
Hmmm... Indeed. Sorry about that.

Other than that, it should've worked. My friend's running it (that's where I got the screenie from.. haven't reinstalled it on my own boards, yet. @_@)

Boofo
21 Jan 2003, 16:24
Is there a way to have this link to the last message shown so all you have to do is click on the link to bring the message up?

Kratheous
21 Jan 2003, 16:33
Yep.

Replace:

$lastpmstuff[title]

With:

<a href="./private.php?s=$session&action=show&privatemessageid=$lastpmstuff[privatemessageid]">$lastpmstuff[title]</a>

Boofo
21 Jan 2003, 16:45
Excellent! Thank you. Great hack! ;)

Sebastian
21 Jan 2003, 18:11
Originally posted by Kratheous
Hmmm... Indeed. Sorry about that.

Other than that, it should've worked. My friend's running it (that's where I got the screenie from.. haven't reinstalled it on my own boards, yet. @_@)

but it doesn't work, if you haven't install it then do so, then tell me if it works. 1 person out of 10 got it to work in this thread, doesn't that tell you something? :ermm:

Boofo
21 Jan 2003, 18:15
Do you have any hacks installed that might be messing with it? I have alot of hacks installed and it works great here.

Kratheous
21 Jan 2003, 18:30
I just installed it on a 2.2.9 and it does work. No hitches, except the one "array" thing, which has been fixed in the posts above. I can't think of a reason where it shouldn't.

Boofo
21 Jan 2003, 19:14
Kratheous, don't forget to update the first post with the Array fix. :) I am running a heavily hacked v2.2.9 and it works fine here, too. Also, I adapted it to work on my vbHome lite page as well.

By the way, the code you gave me for the link to the Latest Private Message was missing a sessionhash. :)

This:

<a href="./private.php?s=$session&action=show&privatemessageid=$lastpmstuff[privatemessageid]">$lastpmstuff[title]</a>


Should be this:

<a href="./private.php?s=$session[sessionhash]&action=show&privatemessageid=$lastpmstuff[privatemessageid]">$lastpmstuff[title]</a>

Slynderdale
22 Jan 2003, 20:43
Ok heres a fix i made to the hack, it uses just 1 query instead of 2, i also added support for firefly's private attachment hack, it also gets the folder name the pm is in, it links the user who sent you the pm to there profile and it also links the message to the pm itself, i fixed up the code and templates, ill post a screenshot below and in the next post the fix. enjoy.

Slynderdale
22 Jan 2003, 20:43
You can find the updated fixed file that shows the correct folder name here:
http://www.vbulletin.org/forum/showthread.php?postid=345000#post345000

MetroSports82
22 Jan 2003, 23:45
um.. not working. I'm getting this message, with new pm's?


You have no PMs in your inbox!

Slynderdale
23 Jan 2003, 00:00
Originally posted by MetroSports82
um.. not working. I'm getting this message, with new pm's?



Hmm, im using it right now and it works, the new pm must be from some one else, not the same user that your checking the pm from, so if you tested by messaging yourself it wont show up as a new pm.

Kratheous
23 Jan 2003, 00:03
Yes, at the time I made this hack, I hadn't discovered joins... it's actually a few months old... *shrugs* And I must be out of it this week, excuse my lack of full variables. @_@

MetroSports82
23 Jan 2003, 00:07
Originally posted by Slynderdale


Hmm, im using it right now and it works, the new pm must be from some one else, not the same user that your checking the pm from, so if you tested by messaging yourself it wont show up as a new pm.

LoL! Doh!! :D it works now. thanks, great hack! ;)

Boofo
23 Jan 2003, 01:05
Originally posted by Slynderdale
Heres the fix.

Thank you, sir, for the folder name addition. Was looking for that one. ;)

Boofo
23 Jan 2003, 03:10
Originally posted by Slynderdale
Heres the fix.

The foldername is always Inbox when the last message I have is in another folder. It's not showing the folder the actual message is in. Any fix for this?

Slynderdale
23 Jan 2003, 03:18
Originally posted by Boofo


The foldername is always Inbox when the last message I have is in another folder. It's not showing the folder the actual message is in. Any fix for this?

Hmm, ill fix that now

Slynderdale
23 Jan 2003, 04:34
Ok, i saw whats wrong and I fixed it and tested it, this now shows the correct folder name its in, enjoy.


Updated, see this post:
http://www.vbulletin.org/forum/showthread.php?s=&postid=394675#post394675

Boofo
23 Jan 2003, 06:17
Thank you again, sir. ;)

mauce
23 Jan 2003, 10:47
eeeh.... may I ask.
Can the folders be made clickable (to make it browse to that folder) as well..

(some people are never satisfied, duh?)

Slynderdale
23 Jan 2003, 11:29
Originally posted by mauce
eeeh.... may I ask.
Can the folders be made clickable (to make it browse to that folder) as well..

(some people are never satisfied, duh?)

in forumhome_pmlast find:

in folder $lastpmstuff[foldername]


change it to:

in folder <a href="private.php?s=$session[sessionhash]&folderid=$lastpmstuff[folderid]">$lastpmstuff[foldername]</a>

I also updated the text file with this.

Slynderdale
13 May 2003, 20:13
Its been a while, any ways, Added a small add on that shows the first 300 chracters of the private message on forumhome.

Boofo
13 May 2003, 20:18
Welcome back, my friend. ;)

Slynderdale
13 May 2003, 20:26
Today at 04:18 PM Boofo said this in Post #40 (http://www.vbulletin.org/forum/showthread.php?postid=394677#post394677)
Welcome back, my friend. ;)

Thanks, latly I pretty much giving up on making hacks for vbulletin till 3.0 comes out. Ive been working on other projects in the mean time. Most for some freinds.

Current Projects (Not intergrated with vbulletin in any way):

Team managment page - user system with user profiles and a admin and user system that allow team admins to create accounts then users to log in and edit there profile.

List List - shows a list of links added by a team admin and also supports banners and tells the status of the site.

Image Gallery with auto thumbnailer

FAQ system that allows people to search FAQ's and team admins to add there own

Projects page - allows the admin to add, edit and delete current prjects and add a screen shot, link, description and other things.

Online dictionary - A custom dictionary where some one can add a word, pronouncian, translation, description and comments. Also with the dictionary withh be a search feature and a text translator feature.

and a bunch of others.

vB-Host.com
14 May 2003, 07:01
Awesome hack.. installed in less then 2 minutes on my www.thesportsforum.net board... thanks for such a cool hack!

Kriek
02 Jun 2003, 22:37
Confirmed working on 2.3.0, however I made a few slight modifcations in the manner that the private message previews are displayed. I noticed that you were utilizing nl2br() (http://www.php.net/nl2br) to convert new lines into <br> which can stretch the layout so I removed the call to that function and added a str_replace() (http://www.php.net/str_replace) to remove carriage returns "\n" and new lines "\n" from the $lastpmstuff['preview'] variable.

Boofo
02 Jun 2003, 23:07
Today at 05:37 PM Kriek said this in Post #43 (http://www.vbulletin.org/forum/showthread.php?postid=403571#post403571)
Confirmed working on 2.3.0, however I made a few slight modifcations in the manner that the private message previews are displayed. I noticed that you were utilizing nl2br() (http://www.php.net/nl2br) to convert new lines into <br> which can stretch the layout so I removed the call to that function and added a str_replace() (http://www.php.net/str_replace) to remove carriage returns "\n" and new lines "\n" from the $lastpmstuff['preview'] variable.

Can you show us what you changed in the code itself?

Kriek
03 Jun 2003, 03:29
Open index.php and find
$lastpmstuff['preview'] = preg_replace("/\[[^\]]*\]/","",$lastpmstuff['message']);
Add the following below it
$lastpmstuff['preview'] = str_replace(array("\n","\r\n","\r")," ",$lastpmstuff['preview']);
Remain in index.php and find
$lastpmstuff['preview'] = trim(nl2br(dowordwrap($lastpmstuff['preview'])));
Replace with the following
$lastpmstuff['preview'] = trim(dowordwrap($lastpmstuff['preview']));

Boofo
03 Jun 2003, 03:55
Here's what I already had for that piece of code and I think it works about the same way, doesn't it?

$lastpmstuff['preview'] = preg_replace("/\[[^\]]*\]/","",$lastpmstuff['message']);
$lastpmstuff['preview'] = str_replace("\"","",$lastpmstuff['preview']);
$lastpmstuff['preview'] = trim(htmlspecialchars($lastpmstuff['preview']));
if (strlen($lastpmstuff['preview']) > 300) {
$lastpmstuff['preview'] = substr($lastpmstuff['preview'], 0, 300) . "…";
}
$lastpmstuff['preview'] = trim(dowordwrap($lastpmstuff['preview'])); // for pm title= preview

Kriek
03 Jun 2003, 04:35
Technically yes, but it will not remove carriage returns and/or new lines.

Boofo
03 Jun 2003, 04:47
I tried it with your code and the message looked all run together. I want it to look like it does in the pm when you preview it.

Kriek
03 Jun 2003, 22:41
Then you completely misunderstood the purpose of my modifcations, as I do NOT want the preview to look like the original private message, because it stretches the layout; imagine a private message with ten or more carriage returns.

Boofo
03 Jun 2003, 22:50
I understand what you mean now. Sorry about that. It is just a little hard to read all bunched together for me. ;)

Kriek
03 Jun 2003, 23:01
No problem, my modifcations are easy enough for you to reverse I hope ;)