1
alain01
PR Add two new events (#941)
  • 2021/2/15 8:48

  • alain01

  • Just can't stay away

  • Posts: 528

  • Since: 2003/6/20


"Add two new events":https://github.com/XOOPS/XoopsCore25/pull/941
Please could you give more explanation ?

1 - First event : core.include.common.auth.success
Quote:
Event is triggered when the establishment, or re-establishment, of the current user is complete.
At this point valid security decisions can be made based on the state of the current user.

Does it means, after that, you could launch action for the user ?
An example please ?
How XOOPS did it before ?

2 - core.class.template.new event
Quote:
This event is triggered when a new XoopsTpl (an extended Smarty object) is created. This allows customization of the Smarty environment from within a module.

One possible use would be to support a module based plugin library. An simplified example event listener:

public static function eventCoreClassTemplateNew($arg)
{
    
$smartyObject $arg[0];
    
$smartyObject->plugins_dir[] = __DIR__;
}

and Mamba continues with this :
Smarty Translate function:https://github.com/XOOPS/XoopsCore25/pull/840/files

function smarty_function_translate($params$smarty)
{
    function 
smarty_function_translate($params$smarty)
    {
            
$key     = isset($params['key']) ? $params['key'] : '';
            
$dirname = isset($params['dir']) ? $params['dir'] : ''//Mtools
            
$utility '\Xoopsmodules\' ucfirst($dirname) . '\Utility';
            return     
$utility::translate($key$dirname);
    }
}


I read "Mtools", so it's a method to use plugin from Mtools in modules ?
Like XMF, but it's another thing, another way ?

Please, could you explain that for a non developper like me ?
Thank you !

Alain

2
Mamba
Re: PR Add two new events (#941)
  • 2021/2/15 11:47

  • Mamba

  • Moderator

  • Posts: 11366

  • Since: 2004/4/23


Reg. the (2) - core.class.template.new event

Till now, in order to use Smarty plugins, they had to be placed in the Core:

htdocs/class/smarty/xoops_plugins /

Now, you'll be able to place your custom Smarty plugins in your module directly, so it will allow for more flexibility, as the users won't need to copy the plugin manually to the Core. As Richard stated:

Quote:
This event is triggered when a new XoopsTpl (an extended Smarty object) is created. This allows customization of the Smarty environment from within a module.

MTools was just a module where I wanted to use this particular plugin, but now you will be able to use any custom Smarty plugin in any of your modules.
Support XOOPS => DONATE
Use 2.5.10 | Docs | Modules | Bugs

3
alain01
Re: PR Add two new events (#941)
  • 2021/2/15 12:34

  • alain01

  • Just can't stay away

  • Posts: 528

  • Since: 2003/6/20


Ok, for flexibility, nice !
Let me know in this subject when you will use this fonction in a module (other than mtools).

This is very interesting!

Login

Who's Online

201 user(s) are online (122 user(s) are browsing Support Forums)


Members: 0


Guests: 201


more...

Donat-O-Meter

Stats
Goal: $100.00
Due Date: Apr 30
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $100.00
Make donations with PayPal!

Latest GitHub Commits