-
-
Notifications
You must be signed in to change notification settings - Fork 412
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add more hooks v2 #882
Comments
> so that we can modify specific portions of the thread items before it is output. **Reference:** http://community.mybb.com/thread-122419.html
> I think one also needs adding above the query to get the threads; the amount of times I want to alter something here and it proves almost impossible. **Reference:** http://community.mybb.com/thread-122419-post-884062.html#pid884062
We should add a hook somewhere around the login function of the Admin CP. Also another place hooks should be added is at the end of the various forms in the Admin CP. This would make it much easier to add to those forms. The hooks could be placed just before $form_container->end(); in the Admin files. |
**Reference:** http://community.mybb.com/thread-100910.html
Update usercp2.php _usercp2_end_ was never to be run.
_syndication_get_posts_ to syndication.php
Update usercp2.php _usercp2_end_ was never to be run.
@PaulBender
What about two in the
But one is already found inside those methods. Would it be really neccessary to add that many new hooks? |
That sounds good. Maybe we can also add some hooks in the new login datahandler too.
I've never been able to get the $form_container->end(); hook to work when I want it to. |
In my opinion:
|
@Destroy666x do you mean something like |
@Sama34, I guess so. |
@PaulBender
Feel free to provide examples so I can see if it is necessary. @Destroy666x can you provide examples where it would be useful? I can't really any case where the current hooks didn't worked.
Yes, you can. Use global_end and do a replacement for a string instead of using a variable. Similar to how the breadcrumb is inserted. |
Indeed that is a wrong placement of a hook. if($mybb->input['action'] == "edit")
{
$plugins->run_hooks("admin_user_users_edit");
$user = get_user($mybb->input['uid']);
// Does the user not exist?
if(!$user['uid'])
{
flash_message($lang->error_invalid_user, 'error');
admin_redirect("index.php?module=user-users");
}
// ...
} Should be: if($mybb->input['action'] == "edit")
{
$user = get_user($mybb->input['uid']);
// Does the user not exist?
if(!$user['uid'])
{
flash_message($lang->error_invalid_user, 'error');
admin_redirect("index.php?module=user-users");
}
$plugins->run_hooks("admin_user_users_edit");
// ...
} All similar behavior should be fixed. member_profile_start in member.php should be run before All hooks should be run after basic confirmation code, etc. Any thoughts? @mybb/developers. |
Any example of this being useful/necessary? I hope you understand there are places we can't simply add new hooks without thinking clear first. (: |
Well, that's why I said 'easily' in my comment. Inserting strings such as <something> and then replacing them looks rather dirty and confusing for me. It's not the biggest deal, but it should be changed in 2.0 if not 1.8 in my opinion. Also, it was suggested by other developers as well as I can see: http://community.mybb.com/thread-140337.html
Never mind, I actually thought about moving $plugins->run_hooks("online_user"); there, but now that I look at while loop in online.php and that function, I can't really remember why as it won't make almost any difference (maybe only if someone wants to use build_wol_row() in a plugin). BTW, does anyone maintain a list of already moved/added hooks in 1.8? |
We can run a diff of the file produced by https://github.com/euantorano/MyBB-Hook-Finder (it wont be too hard to do post-release). |
I think Hooks should add to all of the functions. $date = $plugins->run_hooks("my_date", $date); I think it's bad And this code is good: $argments = array(
"date" => $date,
"format" => $format,
"stamp" => $stamp,
"offset" => $offset,
"ty" => $ty,
"adodb" => $adodb
);
$date = $plugins->run_hooks("my_date", $argments); |
We can't add hooks to every function... That'd be wasted code as you normally don't need to change the behavior of a function. And for the second: you can globalize all of the variables, no need to add them as parameters. |
@JN-Jones But I can't use global for this variables because their only in the my_date function. <?php
// Disallow direct access to this file for security reasons
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$plugins->add_hook("my_date", "mydate");
function mydate_info()
{
return array(
"name" => "My Date Test",
"description" => "",
"website" => "http://www.mybb.com",
"author" => "AliReza_Tofighi",
"authorsite" => "http://www.mybb.com",
"version" => "1.0",
"guid" => "",
"compatibility" => "*"
);
}
function mydate($d)
{
global $format;
echo $format;
exit;
return $d;
}
?> |
@ATofighi it would be better to add them to the global scope than modifying a hook, that could potentially break plug-ins. Why would you need all those variables for? |
I added @mybb/developers |
329421b @PaulBender that was an interesting one, you think that is good enough? |
Yes, that looks good |
What about |
Were the ACP Edit User etc. hooks moved (see my first comment here)? If not, will they be moved? |
They should, however I got not more feedback. There are plenty of places were hooks should be moved a few lines that shouldn't cause issues. |
I think one should be added in else
{
$user['lastvisit'] = my_date('relative', $user['lastactive']);
}
$bgcolor = alt_trow(); But I'm not that sure either. |
Well, there are 2 vs 0, so if noone has anything against it, I guess they can be moved. I can't see any potential danger. I agree with showteam foreach($usergroup['user_list'] as $user){} hook. Either ^there or just anywhere in that loop. |
Wish this had been done as a pull request rather than direct commits. That way I could track what had been added and see if there was any I thought was missing... |
Guys if there's one or two we left out, we can always add later, don't worry about that. If it's done, we can simply close this and move on. |
@euantorano pretty sure every commit referenced here equals to one hook/file. @PirataNervo I would suggest to close this at the last moment. |
Ok, I have moved/added some ACP hooks, I can't fix everything (I hesitated to edit some). I really can't understand the logic behind all hooks in the ACP. Looks like they were added automatically really... |
Alright I'm closing this then, thank you for your work. |
I did some minor modifications. I doubt that will break any plug-in. |
@Sama34 if possible something in line 2781 in functions.php and line 847 of class_page.php without arguments thanks |
@martec, agree |
I think you should also add an hook here: https://github.com/mybb/mybb/blob/feature/inc/datahandlers/post.php#L1219 Handling automatic subscriptions is hard for third party plugins, an hook should help. |
So that notification centers can hook in there? @mybb/developers |
Could a hook be added somewhere in here? I want to do my own way of handling message filtering but I can't do that without editing files, since other files call this function directly. |
@iSnipeu I'm not sure about that. @mybb/developers |
Feel free to suggest necessary hooks.
If you push directly please do so on an one-commit one-hook format unless you feel it not to be necessary (i.e: one-commit one-file). Thanks!
@mybb/developers
The text was updated successfully, but these errors were encountered: