teraßyte Posted October 31, 2018 Posted October 31, 2018 2 hours ago, HeadStand said: You CAN hook into it, as long as it's on a specific class. Meaning, you can hook into \IPS\forums\Topic, just not \IPS\Content\Reactable. Is that not sufficient for what you're doing? Yeah, I can hook into specific classes but not the main one. For example I want to make all apps not save a point for the chosen reputation under certain circumstances. I'd have to go around making an hook on each class for each application I want to support. And I just can't go around adding support for any 3rd party apps 1 by 1. I could do it, but I won't. I'll use my time in better ways 🙂
CodingJungle Posted October 31, 2018 Posted October 31, 2018 25 minutes ago, teraßyte said: Yeah, I can hook into specific classes but not the main one. For example I want to make all apps not save a point for the chosen reputation under certain circumstances. I'd have to go around making an hook on each class for each application I want to support. And I just can't go around adding support for any 3rd party apps 1 by 1. I could do it, but I won't. I'll use my time in better ways 🙂 have you tried telling the class to use the class method instead of the traits method? like: trait FooTrait { public function bar(){ return "hello, i'm a trait method!"; } } class myhook extends HOOK_TEMP { use FooTrait { bar as traitBar; } public function bar() { return "I am not the trait method!"; } } i haven't tested this, but i can think of a potential problem or two.
GTAPoliceMods Posted July 8, 2020 Posted July 8, 2020 Any updates on this? Trying to hook into a trait on 4.4.
teraßyte Posted December 5, 2022 Posted December 5, 2022 5 years later, and everything is still the same... 🙄 👀
Afrodude Posted December 5, 2022 Posted December 5, 2022 1 hour ago, teraßyte said: 5 years later, and everything is still the same... 🙄 👀 Welcome to IPS land where everything can be a dream. SeNioR- 1
Adriano Faria Posted April 26, 2023 Posted April 26, 2023 (edited) ...and almost 6 years later, nothing has changed. I need to hook in \IPS\Content\Reactable::removeReaction() and I can't. I can't add this method to every content item model basically because I don't which apps will be installed on every board out there. Does anyone know any workaround for this? Edited April 26, 2023 by Adriano Faria
teraßyte Posted April 26, 2023 Posted April 26, 2023 I doubt anything will change for 4.x at this point. My only hope is that they'll implement something for 5.x... 🙄 Adriano Faria 1
Adriano Faria Posted April 26, 2023 Posted April 26, 2023 5 minutes ago, teraßyte said: I doubt anything will change for 4.x at this point. My only hope is that they'll implement something for 5.x... 🙄 Are you aware of any workaround for this? I need to hook in removeReaction() :
teraßyte Posted April 26, 2023 Posted April 26, 2023 (edited) @Adriano Faria In the past, I overloaded the function \IPS\Member::__set() checking for the key pp_reputation_points and then checking if the do parameter starts with (un)react. That should cover all areas I believe. # We're updating the 'pp_reputation_points' value and we're (un)reacting if ( $key == 'pp_reputation_points' AND \IPS\Request::i()->do AND ( mb_substr( \IPS\Request::i()->do, 0, 5 ) === 'react' OR mb_substr( \IPS\Request::i()->do, 0, 7 ) === 'unreact' ) AND \IPS\Member::loggedIn()->member_id ) { // Your code } You also need to account for when the reputation is rebuilt though. That check is not included in the example above. It requires hooking the function that rebuilds the count and passing along some kind of flag. If you want to check only removeReaction() skip the do=reactXXX check. That said, this kind of code doesn't let you know which reaction is actually being removed. It only acts on the points being updated. If you require to run it on specific reactions only, I have no idea how, unfortunately. Edited April 26, 2023 by teraßyte DSystem and Adriano Faria 2
Recommended Posts