What I want to achieve is a notification on the forum telling you if you have been quoted since your last visit. I had a look at the new forum posts notification in the login menu, which is as follows:
// ------------ Forum Stats -----------
if (isset($menu_pref['login_menu']['new_forum']) && $menu_pref['login_menu']['new_forum'] == true) { $qry = "SELECT count(*) as count FROM #forum_t as t LEFT JOIN #forum as f ON t.thread_forum_id = f.forum_id WHERE t.thread_datestamp > {$time} and f.forum_class IN (".USERCLASS_LIST.")";
This piece of code checks how many new forum posts there have been since your last visit. What I need to do is check each of these posts if they contain a certain string.
The strings that needs to be checked are:
[.quote{datestamp}=".USERNAME."]
AND
[./quote{datestamp}]
Where the {datestamp} can be any string of numbers or none at all.
Could someone point out to me how I use regular expressions to check for this?
<?php
//------------------------------------------------+
$str = "Hello, this is a quote: [quote1234567890=Crytiqal] and this is an end: [/quote]";
//------------------------------------------------+
$w = "[\s\S]*?"; //ungreedy wildcard
$quote = "/\[quote$w\=Crytiqal\]$w\[\/quote\]/";
//------------------------------------------------+
if (preg_match($quote,$str))
{ $quotes[] += 1; print_r($quotes); echo "match"; } else { echo "no match"; }
//------------------------------------------------+
?>
This seems to work
Now I just have to call this script for each newforumpost[i] and count the number of quotes where the name matches the current users name. When a quote is made, I add this to a quote_array, inwhich I construct a link to that post number where the quote is at.
Anyone interested in me making a menu for this? Is there already a function for this in v0.8? If not, maybe you guys want to use this code when it's finished?
PS: Could the code boxes be a bit bigger? It kinda defeats the purpose of posting code when it's not really readable when put into code boxes...
I'll add it to the feature request as soon as I am done with the entire code. Hopefully it could be in place for the next update, or don't the devs accept community made code?
Actually, it's not the fault of my script but of e107 scripts. When I go to my website, it tells me:
Since your last visit there have been 1 forum post
When I view this post it STILL tells me that since my last visit there has been 1 new forum post.
Why is this not being updated when I have viewed the post??
I notice that the same error applies to this website aswell. It doesn't update the latest posts correctly, does it?
How can this be? Even when I logout and login again it still shows me this message!
Welcome Crytiqal There is 1 new post since your last visit. (You have read 3 of these posts.) You last visited at Wednesday 21 September 2011 - 17:29:03 It is now Wednesday 21 September 2011 - 21:20:26
The forum has always been buggy as is not displaying the information correctly. The same goes for unread/read posts. McFly was working on a complete rewrite of the forum in v0.8 but as he left, I haven't seen progress on it.
When is e107 going to search for more talent to help them in development?
My plugin won't be working correctly if the forum isn't working correctly...
PS: I might be able to code a multiquote function in aswell
PPS: Seriously, how can the community help in development with this CMS? I feel like we all just have to sit and wait for the devs to release whenever they feel like releasing info and we are all dogs waiting for a bone. This needs to change! Obviously there is not a large community if the community is left out and left in the dark... :/
Please don't start another discussion over this, we got 2 rolling already. Yes you are absolutely correct but this is not the topic to discuss it in. Some of the support team members are working on getting the dev's to make some changes like you mentioned.
---
If proper coding is supplied the support team and the admins will definitely help you getting attention from the devs to integrate it.
--
Well there should be some sort of logic, it is not random. But it's not functioning like it should either (There is 1 new post since your last visit. You have read 3 of these posts. ==> logic seems to be absent) Again, If proper coding is supplied the support team and the admins will definitely help you getting attention from the devs to integrate it.
However, I must say that a complete rewrite would be less work compared to debugging and fixing the issues in the current forum version....
I went back to my website today, and now the new post message is gone.
Correct me if I am wrong, but I think the datestamp is set per day, and maybe this needs to be more precise by hours even even minutes.. (timestamp would be the better word for it then )
Maybe someone could look into this? Or point me in the right direction? I think the times are stored using that unix timestamp thingy..
How to convert?
Also, how far did McFly get with his forum v0.8 overhaul? Was it working already? If the groundwork is set, maybe the community could help adding the functionality of the forum?
EDIT: Just found out it also shows new forum posts when I am the one posting them.. lol
McFly did start it as a complete re write, then withdrew it all from cvs (pre svn) but I don't know why.
I suspect it's all down to the total changes to js handling and the new userclass system in 0.8 that needs to be completed first, but I'm not 100% sure
So I can't really finish this addition then, since the New Forum Posts Since Last Visit need to work first...
I had some idea's on how multiquote could work aswell. In vBulletin4 you can put a checkmark next to the posts you want to quote, and when you press reply it fills the reply box with those checked posts in quote wraps.
Also, when going "advanced replying" maybe the reply message could temp be saved and you can view the forum above the reply box. You could be able to switch pages and the reply box would still contain it's message.
Then you could quote multiple people over different pages while writing your message
Anyway, I would kinda be willing to help the dev team out with a new forum... I don't know very much about mysql and db structures tho, but I could help on the layout, and the few idea's I posted earlier. Maybe me and 2 other devs could get to work on a forum plugin for v0.8?
I don't know how much affect 0.8 would have on the forum, but I would think the main things would be independant of the new userclass tree structure right?
My experience with php is mostly shown on my own website where I add bits and pieces and modify existing plugins aswell as write my own bits of php code. Like an email signup page where users can create their own email @mydomain.org account. Later they can edit it or remove aswell. Without a mysql database but written in plain text file because MercuryMail uses those. Also they were stored in alphabetical order, even after editing/removing etc. Eventho the first character in front of their names was either an A or an U for Admin or User
I also made a live server log viewer which tails the gameserver log into a html page so you can view the logfile live.
My website template is also coded by myself. Just some examples in my experience with php.
Imo, this would be the cleanest and quickest structure. As you can see the overhead id's get carried over to the underlying tables so you can easily sort everything by parent/forum/thread/post id.
Also you can easily sort posts by timestamp etc.
I know a bit about php and mysql, but I don't know about optimization etc. I do have a few idea's that maybe together with a team of 3 could result in a new forum plugin...
I think I came up with a way to retrieve the correct amount of new messages on the forum.
Bare with me on this:
user browses a forum, on every forumpage open or refresh he get's a timestamp stored in user_forum_newtimestamp when the user browser to another page, the forum puts user_forum_newtimestamp and stores it in --> user_forum_oldtimestamp, checks if there have been any new posts since the oldtimestamp, and gives the user a user_forum_newtimestamp.
When the user leavs, he will leave with a value stored in user_forum_newtimestamp.
If the user comes back the next day, the forum puts user_forum_newtimestamp and stores it in --> user_forum_oldtimestamp, checks if there have been any new posts since the oldtimestamp, and gives the user a user_forum_newtimestamp.
All the posts that have been made since user_forum_oldtimestamp and user_forum_newtimestamp get stored in a temporary user array. Every entry in the array get's a timestamp when they have been added to that array, and if they are longer than 30 minutes in that array they will get removed. If the user views the thread in which a post is made that is stored in that array, it will get removed from that array aswell.
One of the big changes to the forum was to be a new DB table structure which I see your proposing so that threads could be merged and individual posts moved to another thread.
That's one of the major downsides of e107 forums as they stand.
But, it also means a conversion tool to run during the upgrade for existing forums.
ATM even though I keep pruning the forums I have 106,702 Posts in 10,347 Topics which I would hate to break.
Ideally, the forum plugin would have been re written for v0.7 so those that don't want all the proposed 0.8 features could stick with it but have better forum management
I think a conversion tool for the forum change wouldn't be that hard to create
I would gladly build this forum, but my knowledge on creating mysql tables and storing into tables efficiently is not something I have great experience in, eventho I know what I'd have to do. I am not confident enough that my code would be the most efficient on those parts.
That being said, I am a quick learner by example and having to work with 1 or 2 others that do have this experience, I would love to work on a forum plugin for v0.8. It would also work for 0.7 I'd reckon.