51 (edited by qubertman 2008-02-17 01:12)

Re: Hook requests

footer.php (line 103)
- Hook to retrieve to modify the query.

Re: Hook requests

qubertman wrote:

footer.php (line 103)
- Hook to retrieve to modify the query.

Added

http://fluxbb.org

Free PunBB Hosting - lots of mods, easy to customize

53 (edited by daris 2008-02-22 17:42)

Re: Hook requests

At start of generate_crumbs function for modify crumbs array (i need it to add at start portal page)

edit: i didn't need this hook, because i can modify it from some header hooks

Re: Hook requests

Can we get a hook in search.php after line 761 ("$db->free_result($result);") so an extension can do things with the $search_set array?

Re: Hook requests

intedinmamma wrote:
Rickard wrote:

Anyone else have an idea?

if(count(array_intersect($perms_new, $perms_old)) != count($perms_new))
{
    if(count(array_intersect($perms_new, $perms_default)) == count($perms_new))
    {
        // Delete
    }
    
    else
    {
        // Insert/Update
    }
}

It should be quite easy to build the queries and the form directly from $perms. If done right, you will just have to add elements to $perms and $perms_default to add permissions. Forms, validation and queries are so similar that it will work most of the time, and when it doesn't you can always use some other hook. Depending on how it's all implemented you might have to use array_intersect_assoc() instead of array_intersect(), as the latter doesn't care about indexes.

Nice idea. I've committed it. I used regular array operators to do the comparison though.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Hook requests

A hook in functions.php outside the functions would allow to add custom ones.

Re: Hook requests

I think I got all of them (that made sense anyway big_smile): http://dev.punbb.org/changeset/1521

Strofanto: We can't do that in functions.php because by the time we include functions.php, the hooks system hasn't been initialized yet. I recommend you use co_common instead.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Hook requests

Rickard wrote:

We can't do that in functions.php because by the time we include functions.php, the hooks system hasn't been initialized yet. I recommend you use co_common instead.

Gotcha. Thanks.

Re: Hook requests

We need a hook in include/common_admin.php (function generate_admin_menu) to add main tabs to the admin menu.

FluxBB - v1.4.8

Re: Hook requests

Done.

"Programming is like sex: one mistake and you have to support it for the rest of your life."

Re: Hook requests

i have a little idea about hooks ... i dont know how many hooks must be added to complete

a new hook may be needed any time ... even after the release .... so i came up with the idea ....

can it be possible to make hook page in admin area that places hooks in the files or into 1 file and then that file will spread to other files...

or

for extension you need specific hooks ... so post the hooks in the readme file and that hooks to the page of hooks in the admin area ...

just an idea

MyFootballCafe.com  is Now Online!

Re: Hook requests

What? If I understand your post, which I doubt, no.

63 (edited by Kyle 2008-03-02 20:21)

Re: Hook requests

There's a vf_table_header_after_num_views and vf_table_contents_after_num_views, why not some for before num_views?

Wouldn't all the columns (including headers) be much more malleable if they were stored in an ordered numbered array rather than as associative array?

Re: Hook requests

Wouldn't all the columns (including headers) be much more malleable if they were stored in an ordered numbered array rather than as associative array?

I don't see how.

65 (edited by Adam Atlas 2008-03-06 05:17)

Re: Hook requests

In general, wouldn't it be good to keep the hook layout consistent (where applicable) between the topic-listing parts in viewforum.php, moderate.php, and search.php?

Today I'm wondering if you could add a hook in each somewhere after $pun_page['item_status'] is set but before $pun_page['item_style'] and $pun_page['item_indicator'] are generated.

Edit: By the way, why is the "($hook = get_hook(...)) ? eval($hook) : null;" boilerplate necessary? If you had get_hook return '' instead of false when there are no entries for a given hook, you could just do "eval(get_hook(...));". I think that would be good for readability.

Re: Hook requests

You'd still be calling eval() uselessly then, which I'm sure is slower than a little check, even with false as the argument.

67 (edited by Adam Atlas 2008-03-06 08:35)

Re: Hook requests

You're right, I must admit. I did some testing, and I found that while a "($hook = get_hook(...)) ? eval($hook) : null;" statement can execute on my computer almost 2.23 million times per second, "eval(get_hook(...));" can only execute a pathetic 1.26 million times. yikes tongue

(On a trip to viewtopic.php just now, I found that 159 undefined hooks were called. By my calculations, this means one second would be wasted after 18,294 calls to viewtopic.php. My moderately-high-traffic forum got 62,083 hits to viewtopic.php last month, which means that if the modified hook code had been used at the time, viewtopic.php would have wasted approximately 3.4 CPU-seconds over the month. Is this deemed acceptable or not?)

Re: Hook requests

For forum software like this, it isn't very acceptable indeed =P 3.4 CPU seconds is actually quite alot.

69

Re: Hook requests

I've already stated in another thread than "eval" function is one of SLOWEST call in php (and in other languages as well..).
Seeing the reacts at that time, i've stopped "informing" (as it was somehow considered as "complaining", which obviously was not).
The conclusion for me : let's "wait and see"...
Basically, it's obvious that an 'extension' will be slower than its corresponding 'mod'. But, is this really noticeable (or become a problem), we don't know as today.
And is the 'extension' system in a whole worth the slowdown, we don't know either, even if i'm tempted to think YES (before having testing any extension..), for the simplicity of extensions against mods.

Re: Hook requests

Indeed. People tend to only think about how much CPU time it might waste, but think of all the programmer and administrator time saved by the extension system! smile

Re: Hook requests

Oh, I don't have much against this extension system tongue It should just be as optimised as possible.

Re: Hook requests

Mpok: Nobody said you were complaining, or even answered your posts in a hostile manner. wink
If you have an alternative to calling eval, we would love to hear it. However, we have tested several methods and eval is not the slowest of them. It also has the advantage that any extension code is run in the global scope, which simplifies things for extension authors. smile

http://fluxbb.org

Free PunBB Hosting - lots of mods, easy to customize

Re: Hook requests

gud thanks .

Re: Hook requests

When are the hooks in parser.php coming so that people can make there own bbcode?

Re: Hook requests

When the new parser comes, I'd guess.