xoops forums

alain01

Just can't stay away
Posted on: 2/15 8:48
alain01
alain01 (Show more)
Just can't stay away
Posts: 481
Since: 2003/6/20
#1

PR Add two new events (#941)

"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

Mamba

Moderator
Posted on: 2/15 11:47
Mamba
Mamba (Show more)
Moderator
Posts: 11155
Since: 2004/4/23
#2

Re: PR Add two new events (#941)

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

alain01

Just can't stay away
Posted on: 2/15 12:34
alain01
alain01 (Show more)
Just can't stay away
Posts: 481
Since: 2003/6/20
#3

Re: PR Add two new events (#941)

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!