Find new quotes

e107 CMS » Forums » e107 Code » Plugin / Code Developer Discussion << Previous thread | Next thread >>
Go to page  1 2
Crytiqal
Sep 20 2011, 10:53AM
  • e107 Support Team
Registered Member #53493
Joined: Oct 31 2009, 04:55AM
Location: Looks like a room...
Posts: 539
Hello forum,

I am in need of some help with an idea I had.

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.")";

if($sql->db_Select_gen($qry))
{
$row = $sql->db_Fetch();
$new_forum = $row['count'];
$new_total += $new_forum;
}

if (!$new_forum) {
$new_forum = LOGIN_MENU_L26;
}
$NewItems[] = $new_forum.' '.($new_forum == 1 ? LOGIN_MENU_L20 : LOGIN_MENU_L21);
}


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?

Thanks in advance for those willing to help!

Greetings,
Crytiqal
[ Edited Sep 20 2011, 10:54AM ]
Go to top
Crytiqal
Sep 21 2011, 12:35AM
  • e107 Support Team
Registered Member #53493
Joined: Oct 31 2009, 04:55AM
Location: Looks like a room...
Posts: 539
As based on the following post: [-link-]

$w = "[\s\S]*?"; //ungreedy wildcard
$pattern1 = "/\[quote$w\=\".USERNAME.\"\]/";
$pattern2 = "/\[\/quote\]/";

Would these be the correct preg_match patterns?
[ Edited Sep 21 2011, 05:39AM ]
Go to top
Crytiqal
Sep 21 2011, 03:10AM
  • e107 Support Team
Registered Member #53493
Joined: Oct 31 2009, 04:55AM
Location: Looks like a room...
Posts: 539
What I have so far:

<?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...
[ Edited Sep 21 2011, 05:20AM ]
Go to top
C6Dave
Sep 21 2011, 05:08AM
C6Dave
  • e107 Support Team Leader
Registered Member #9506
Joined: Jul 31 2004, 12:57AM
Location: North East UK
Posts: 12632
The code box is only there for 'snippets' e.g. a line or 2 as far as I'm aware

Longer code posts should really go in the Paste Bin (under the Misc) link in the main menu)

It needs a theme css change (I think) to have a larger code box but I don't have access

Having the option to see who has quoted you seems like a good idea, so why not add it to 'feature requests' with a link back to this thread?
Go to top
Website
Crytiqal
Sep 21 2011, 07:45AM
  • e107 Support Team
Registered Member #53493
Joined: Oct 31 2009, 04:55AM
Location: Looks like a room...
Posts: 539
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?
Go to top
Crytiqal
Sep 21 2011, 12:18PM
  • e107 Support Team
Registered Member #53493
Joined: Oct 31 2009, 04:55AM
Location: Looks like a room...
Posts: 539
I have a small problem with my script....

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
[ Edited Sep 21 2011, 12:20PM ]
Go to top
Moc
Sep 21 2011, 01:17PM
Registered Member #44563
Joined: Apr 12 2008, 03:01AM
Location: The Netherlands
Posts: 4278
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.
Go to top
Crytiqal
Sep 21 2011, 02:15PM
  • e107 Support Team
Registered Member #53493
Joined: Oct 31 2009, 04:55AM
Location: Looks like a room...
Posts: 539
Oh dear

That IS bad news..

So the 0.8 forum won't be ready?

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... :/
[ Edited Sep 21 2011, 02:19PM ]
Go to top
Crytiqal
Sep 21 2011, 02:52PM
  • e107 Support Team
Registered Member #53493
Joined: Oct 31 2009, 04:55AM
Location: Looks like a room...
Posts: 539
Is there any logic behind the calculation or does it just display random numbers?

There must be some way it has to come up with the output right?

Then there must be some way to fix it aswell.

I'll post a suggestion for correct post tracking tomorrow. I'll sleep over the idea tonight.

And please let some dev take notice. We are here trying to help this cms ...
Go to top
Moc
Sep 21 2011, 03:07PM
Registered Member #44563
Joined: Apr 12 2008, 03:01AM
Location: The Netherlands
Posts: 4278
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....

[ Edited Sep 21 2011, 03:27PM ]
Go to top
Crytiqal
Sep 22 2011, 06:02AM
  • e107 Support Team
Registered Member #53493
Joined: Oct 31 2009, 04:55AM
Location: Looks like a room...
Posts: 539
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
[ Edited Sep 22 2011, 06:47AM ]
Go to top
C6Dave
Sep 22 2011, 06:55AM
C6Dave
  • e107 Support Team Leader
Registered Member #9506
Joined: Jul 31 2004, 12:57AM
Location: North East UK
Posts: 12632
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
Go to top
Website
Crytiqal
Sep 22 2011, 07:37AM
  • e107 Support Team
Registered Member #53493
Joined: Oct 31 2009, 04:55AM
Location: Looks like a room...
Posts: 539
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
Go to top
C6Dave
Sep 22 2011, 08:29AM
C6Dave
  • e107 Support Team Leader
Registered Member #9506
Joined: Jul 31 2004, 12:57AM
Location: North East UK
Posts: 12632
I have seen the multi quote option on another forum (can't remember what though) and it is a good idea

I think it was Ajax driven
Go to top
Website
Crytiqal
Sep 22 2011, 08:58AM
  • e107 Support Team
Registered Member #53493
Joined: Oct 31 2009, 04:55AM
Location: Looks like a room...
Posts: 539
[-link-] has it for example

EDIT: Oh you cant see it without logging in.


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.
[ Edited Sep 22 2011, 09:10AM ]
Go to top
Crytiqal
Sep 23 2011, 01:44AM
  • e107 Support Team
Registered Member #53493
Joined: Oct 31 2009, 04:55AM
Location: Looks like a room...
Posts: 539
The easiest db structure I think would be:

a table for the parents:
e107_forum_p
  • forum_parent_id
  • forum_parent_name
  • forum_parent_discription
  • forum_parent_class
  • forum_parent_postclass
  • forum_parent_order


a table for the forums:
e107_forum_f
  • forum_parent_id
  • forum_forum_id
  • forum_forum_name
  • forum_forum_discription
  • forum_forum_class
  • forum_forum_postclass
  • forum_forum_moderators
  • forum_forum_order


a table for the threads:
e107_forum_t
  • forum_parent_id
  • forum_forum_id
  • forum_thread_id
  • forum_thread_name
  • forum_thread_thread
  • forum_thread_order
  • forum_thread_views
  • forum_thread_timestamp
  • forum_thread_posts
  • etc


a table for the posts:
e107_forum_posts
  • forum_parent_id
  • forum_forum_id
  • forum_thread_id
  • forum_post_id
  • forum_post_user
  • forum_post_post
  • forum_post_timestamp
  • etc
[ Edited Sep 23 2011, 01:48AM ]
Go to top
Crytiqal
Sep 23 2011, 01:54AM
  • e107 Support Team
Registered Member #53493
Joined: Oct 31 2009, 04:55AM
Location: Looks like a room...
Posts: 539
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...
[ Edited Sep 23 2011, 01:54AM ]
Go to top
Crytiqal
Sep 23 2011, 08:34AM
  • e107 Support Team
Registered Member #53493
Joined: Oct 31 2009, 04:55AM
Location: Looks like a room...
Posts: 539
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.


[ Edited Nov 14 2011, 02:51AM ]
Go to top
C6Dave
Sep 23 2011, 08:49AM
C6Dave
  • e107 Support Team Leader
Registered Member #9506
Joined: Jul 31 2004, 12:57AM
Location: North East UK
Posts: 12632
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
Go to top
Website
Crytiqal
Sep 23 2011, 09:20AM
  • e107 Support Team
Registered Member #53493
Joined: Oct 31 2009, 04:55AM
Location: Looks like a room...
Posts: 539
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.
[ Edited Sep 23 2011, 09:27AM ]
Go to top
Go to page  1 2  

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System