Forum development for v0.8

e107 CMS » Forums » e107 Code » Plugin / Code Developer Discussion << Previous thread | Next thread >>
Go to page  1 2 3 4 5
DigitalArtist
Oct 03 2011, 08:29AM
If you code it they will come.
Registered Member #1133
Joined: Mar 13 2003, 07:54PM
Location: Binghamton, NY
Posts: 2163
thanks for the info. I'll take a look at that
Go to top
Crytiqal
Oct 06 2011, 05:39AM
  • e107 Support Team
Registered Member #53493
Joined: Oct 31 2009, 04:55AM
Location: Looks like a room...
Posts: 539
Just a headsup that I have sparetime again so I can work on coding again
Go to top
aomtealfox
Oct 06 2011, 11:27AM
Registered Member #7026
Joined: May 18 2004, 01:33PM
Location: Brussels, Belgium
Posts: 929
Everyone, duck! There's 000's and 111's about to fly
Go to top
Website
DigitalArtist
Oct 07 2011, 06:59AM
If you code it they will come.
Registered Member #1133
Joined: Mar 13 2003, 07:54PM
Location: Binghamton, NY
Posts: 2163
nlstart wrote ...

For 0.8 Prototype and Scriptaculous libraries are supported: http://e107.svn.sourceforge.net/viewvc/e107/trunk/e107_0.8/e107_files/jslib/


Prototype is now ver 1.7 (e107 is using ver 1.6) and scriptaculous is ver 1.9.0 (e107 is using ver 1.8.3) Just mentioning it in case someone wants to update what e107 is using.
Go to top
Crytiqal
Oct 07 2011, 11:41AM
  • e107 Support Team
Registered Member #53493
Joined: Oct 31 2009, 04:55AM
Location: Looks like a room...
Posts: 539
Hey everyone..

in the table forum_posts, I would only need
forum_post_id
forum_thread_id

then in forum_thread table, I would have:
forum_thread_id
forum_forum_id

and in forum_f:
forum_forum_id
forum_parent_id

in forum_p
forum_parent_id


No need to carry more then 1 parent id over to the child right?
I wouldn't need forum_parent_id, forum_forum_id, forum_thread_id AND forum_post_id in forum_posts table right?

It would be overkill?
Or would it be easier if I carried all the id's over like I had posted earlier?

I am now making a parent delete function, so I need to delete the parent and all the forums, threads and posts associated with it.
If I only carry over 1 previous id over to the underlying table, I would need to first
query the forum_f for the forum_forum_id where forum_parent_id = $_GET['id'] and store this in $forum_forum_id
Then query forum_t for the forum_thread_id where forum_forum_id = $forum_forum_id and store this in $forum_thread_id
Then query forum_posts for the forum_post_id where forum_thread_id = $forum_thread_id

And then delete those recursivly.
Otherwise it would be;

delete parent,forum,thread, posts where forum_parent_id = $_GET['id']

However, does this take extra load on reading the forum with this extra info pulled from the db?
Or can I just skip querying this info from the mysql db and speed things up?
(so instead of SELECT * I select everything except the more than 1 parent id?)



What you guys think?
[ Edited Oct 07 2011, 11:52AM ]
Go to top
Crytiqal
Oct 07 2011, 02:10PM
  • e107 Support Team
Registered Member #53493
Joined: Oct 31 2009, 04:55AM
Location: Looks like a room...
Posts: 539
Just a small clarification:

IF I ONLY give the thread_id to the posts,
the forum_id to the threads,
and the parent_id to the forums,

I would need to make several arrays for which to check which posts to delete when a parent would get deleted.

check parent_id (pid), check forum_id (fid) for which parent_id is pid and place them in an array,

foreach $key->$value, check which thread_id (tid) has forum_id = $value and store this in an array.

Then check posts which have thread_id.

I don't know if this is beneficial to do, or just store all the overlaying id's in all the child tables like in this post: [-link-]
[ Edited Oct 07 2011, 02:12PM ]
Go to top
Crytiqal
Oct 08 2011, 03:58AM
  • e107 Support Team
Registered Member #53493
Joined: Oct 31 2009, 04:55AM
Location: Looks like a room...
Posts: 539
I think I will only give through the parent_id #.

So forum_p gets forum_parent_id,
forum_f gets forum_parent_id AND forum_forum_id,
forum_t gets forum_forum_id AND forum_thread_id,
forum_posts gets forum_thread_id AND forum_post_id

When moving forums or threads around, this would save some time I guess.
Loading threads will still be the same speed as before, (as you won't load overheading id's anymore, just 1)
[ Edited Oct 08 2011, 08:34AM ]
Go to top
Crytiqal
Oct 08 2011, 08:35AM
  • e107 Support Team
Registered Member #53493
Joined: Oct 31 2009, 04:55AM
Location: Looks like a room...
Posts: 539
I see in e107_user table the following columns:

user_lastvisit, user_currentvisit

I wonder if they work the same way I wanted to do my user_forum_oldtimestamp and user_forum_newtimestamp...

Cause then I might be able to use just these variables...?
Go to top
DigitalArtist
Oct 08 2011, 07:51PM
If you code it they will come.
Registered Member #1133
Joined: Mar 13 2003, 07:54PM
Location: Binghamton, NY
Posts: 2163
I think the current visit becomes the last visit the next time you show up and a new current visit is saved.
Go to top
Crytiqal
Oct 09 2011, 01:28AM
  • e107 Support Team
Registered Member #53493
Joined: Oct 31 2009, 04:55AM
Location: Looks like a room...
Posts: 539
DigitalArtist wrote ...

I think the current visit becomes the last visit the next time you show up and a new current visit is saved.


I did some checking the other day and here is what I find out:

Before I go to my website, I check the mysql table for the user_lastvisit and user_currentvisit.
For example: My last visit was 2 days ago, and my current visit was from yesterday evening.
I then go to my website, and refresh the mysql table after.
Now, my last visit was from yesterday, and my current visit is the present.
When I navigate to another page, my last visit is STILL from yesterday, and my current visit refreshes to the current present.

In other words, the last visit isn't being updated everytime a page refreshes, so I don't know when this gets updated?
Also, this means it is useless to track new forum posts, otherwise read posts would still show up as unread, as I explained earlier.
I will need to use my own function for this then, and mysql table columns
Go to top
Luceos
Oct 10 2011, 11:46PM
  • e107 Support Team
Registered Member #23465
Joined: Jan 04 2006, 01:15AM
Location: Netherlands
Posts: 837
Isn't last visit the last time you log in?
Go to top
Website
Crytiqal
Oct 15 2011, 04:29AM
  • e107 Support Team
Registered Member #53493
Joined: Oct 31 2009, 04:55AM
Location: Looks like a room...
Posts: 539
No, I'm always logged in.

I am not sure what it is...but in any case it's not suited to find new forum posts
Go to top
Crytiqal
Oct 15 2011, 07:29AM
  • e107 Support Team
Registered Member #53493
Joined: Oct 31 2009, 04:55AM
Location: Looks like a room...
Posts: 539
I made this little function to keep the forum_p table always sorted and ordered.

Basicly, you can set the incremental ID yourself when creating a parent.
If the ID already exists, it brings you to the edit page of that parent, else you can create a parent with that forum_parent_id.
Same for editing, if the parent with the id you specified doesn't exist, it brings you to the create page for that parent.


function create_parents($sub_action, $id)
{
global $sql, $ns;

// ---------------------------------------------------------------------------------------------+

if ($sub_action == "create")
{
if ($sql->db_Select("forum_p", "*", "forum_parent_id=$id"))
{
header("location:".e_SELF."?parents.edit.$id");
exit;
}
}
if ($sub_action == "edit" && !$_POST['update_parent'])
{
if ($sql->db_Select("forum_p", "*", "forum_parent_id=$id"))
{
$row = $sql->db_Fetch();
extract($row);
}
else
{
header("location:".e_SELF."?parents.create.$id");
exit;
}
}
if ($sub_action == "delete" && !$_POST['delete_parent'])
{
if ($sql->db_Select("forum_p", "*", "forum_parent_id=$id"))
{
$row = $sql->db_Fetch();
extract($row);
}
else
{
header("location:".e_SELF."?parents.create.$id");
exit;
}
}


Then I also added something cause I am neat;


if(isset($_POST['submit_parent']))
{
$_POST['forum_parent_name'] = $tp->toDB($_POST['forum_parent_name']);
$_POST['forum_parent_description'] = $tp->toDB($_POST['forum_parent_description']);
$sql->db_Insert("forum_p", "$id, '".$_POST['forum_parent_name']."', '".$_POST['forum_parent_description']."', '".$_POST['forum_parent_class']."', '{$_POST['forum_parent_postclass']}', '0'");
mysql_query("ALTER TABLE e107_forum_p ORDER BY forum_parent_id ASC") or die (mysql_error());
show_message(FORLAN_13);
}

if(isset($_POST['update_parent']))
{
$_POST['forum_parent_name'] = $tp->toDB($_POST['forum_parent_name']);
$_POST['forum_parent_description'] = $tp->toDB($_POST['forum_parent_description']);
$sql->db_Update("forum_p", "forum_parent_name='".$_POST['forum_parent_name']."', forum_parent_description='".$_POST['forum_parent_description']."', forum_parent_class='".$_POST['forum_parent_class']."', forum_parent_postclass='{$_POST['forum_parent_postclass']}' WHERE forum_parent_id=$id");
show_message(FORLAN_14);
$action = "main";
}

if(isset($_POST['delete_parent']))
{
$sql->db_Delete("forum_p", "forum_parent_id='$id'");
mysql_query("ALTER TABLE e107_forum_p AUTO_INCREMENT = $id, ORDER BY forum_parent_id ASC") or die (mysql_error());
$sql->db_Close();
show_message(FORLAN_14);
$action = "main";
}


(Don't mind the FORLAN cause its only raw code)
What this does is:
If you delete the latest parent it will make sure the next parent you create is with the incremental ID of the latest table entry. This way you don't have emtpy values.

Example:
You have 10 entries, and you delete 9-10.
Next value would be 11, but now, the value will be 9 and up again.

If you specify an ID number, you can fill in the gaps if you want.

Example:
You have 10 entries, and you delete 4-5.
You can specify ID = 4.
It then it orders them all correctly in the table again. (So ID 4 won't be the last entry, but is sorted again)
[ Edited Oct 15 2011, 07:34AM ]
Go to top
Crytiqal
Oct 15 2011, 02:42PM
  • e107 Support Team
Registered Member #53493
Joined: Oct 31 2009, 04:55AM
Location: Looks like a room...
Posts: 539
I have a question regarding db access:

If I use the following statement:

$sql->db_Select("forum_p", "*");

OR

$mysql_table = "forum_p";
$mysql_result = mysql_query("SELECT * FROM ".MPREFIX."$mysql_table") or die(mysql_error());

which one is better?

Using db_Select() would make the forum less stand alone right?
Since this function is from e107 and not a native php function right?
What is the benefit of using this function? [-link-]
[ Edited Oct 16 2011, 01:49AM ]
Go to top
Crytiqal
Oct 18 2011, 09:17AM
  • e107 Support Team
Registered Member #53493
Joined: Oct 31 2009, 04:55AM
Location: Looks like a room...
Posts: 539
I have another question regarding list retreaval:


<tr>
<td style='width:40%' class='forumheader3'>".FORLAN_31.":</td>
<td style='width:60%' class='forumheader3'>";

$sql->db_Select("forum_p", "*", "forum_parent_id");
$text .= "<select name='forum_parent_id' class='tbox'>\n";
while (list($forum_parent_id_, $forum_parent_name_) = $sql->db_Fetch())
{
extract($row);
if ($forum_parent_id_ == $forum_parent)
{
$text .= "<option value='$forum_parent_id_' selected='selected'>".$forum_parent_name_."</option>\n";
}
else
{
$text .= "<option value='$forum_parent_id_'>".$forum_parent_name_."</option>\n";
}
}
$text .= "</select>
</td>
</tr>


I used the code from the original forum as an example and edited for us in the current forum.

Question:
Why is there a "_" suffix ?
[ Edited Oct 18 2011, 09:19AM ]
Go to top
Crytiqal
Oct 18 2011, 10:02AM
  • e107 Support Team
Registered Member #53493
Joined: Oct 31 2009, 04:55AM
Location: Looks like a room...
Posts: 539
And another question:


<input type='hidden' name='e-token' value='".e_TOKEN."' />


Do I have to provide this input on every form aswell?
[ Edited Oct 18 2011, 10:04AM ]
Go to top
Crytiqal
Oct 18 2011, 12:17PM
  • e107 Support Team
Registered Member #53493
Joined: Oct 31 2009, 04:55AM
Location: Looks like a room...
Posts: 539
Ok, I have answered a few questions by myself, only the e_TOKEN question remains as of so far.

my gut tells me it should be in every form, but I would love to have some expert input on that .

For the rest, I am almost done with the groundwork I think.
Creating parents and forums is working.

Why would you set a viewclass and a postclass in a parent AND in the forums?

Wouldn't it be better to set this in the parent and keep this in the forums?

Some thoughts on this please
[ Edited Oct 19 2011, 05:15AM ]
Go to top
Moc
Oct 18 2011, 12:27PM
  • e107 Site administrator
  • e107 Security Team
  • e107 Support Team
  • e107 Documentation Team
Registered Member #44563
Joined: Apr 12 2008, 03:01AM
Location: The Netherlands
Posts: 3517
As for the etoken, I would agree it would have to be included in every from but I'm no expert on that so hopefully someone who is can comment on it.

As for the seperation of view and post class per parent/forum. In situation where for example you want a forum category to be readable by a specific class, but you want one of the forums limited to posting to another userclass. I use this on quite a few installations myself.
Go to top
nlstart
Oct 18 2011, 11:20PM
nlstart
  • e107 Site administrator
  • e107 Core developer
  • e107 Translation Team Leader
Registered Member #29855
Joined: Aug 18 2006, 01:12AM
Location: Utrecht, The Netherlands
Posts: 5489
Crytiqal wrote ...

And another question:
<input type='hidden' name='e-token' value='".e_TOKEN."' />

Do I have to provide this input on every form as well?
Yes, each form needs to have this (I personally expect it as logical to put the hidden e-token input just before the submit button).
Do not forget to check it at the top of each program before calling class2 like this:
if(!isset($_POST['e-token']))
{ // set e-token so it can be processed by class2
$_POST['e-token'] = '';
}
require_once('../../class2.php');
[ Edited Oct 18 2011, 11:22PM ]
Go to top
Website
Crytiqal
Oct 19 2011, 01:58PM
  • e107 Support Team
Registered Member #53493
Joined: Oct 31 2009, 04:55AM
Location: Looks like a room...
Posts: 539
Right, this also fixed a " Access denied" upon processing the user_time installation form.

Is the e_TOKEN only needed at the backend? Or also in the frontend?
Go to top
Go to page  1 2 3 4 5  

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