Joomla 1.5 com_user并导入用户插件,例如Joomla 1.6及更高版本 [英] Joomla 1.5 com_user and importing user plugins like Joomla 1.6 and above

查看:114
本文介绍了Joomla 1.5 com_user并导入用户插件,例如Joomla 1.6及更高版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在前端访问Joomla 1.6和1.7中的com_users组件时,应用程序会自动从用户"组中导入所有插件.显然,如果不想创建一个组件来简单地将一些变量传递给插件,这将非常有用.

When accessing com_users component in Joomla 1.6 and 1.7 on front-end the application automatically imports all plugins from 'user' group. Obviously it is very useful if one doesn't want to create a component to simply pass some variables to a plugin.

好的.让它变得更简单:

Ok. let's make it simplier:

  1. 用户获得激活链接:
  2. 然后JAp​​plication从' user '组导入所有插件,这将触发__constructors
  1. User gets an activation link: http://example.com/index.php?option=com_users&task=edit&emailactivation=1&u=63&d077b8106=1 and clicks it.
  2. Of course the component will omit emailactivation and other params simply displying "Edit Profile Form" (or login form for guests).
  3. Then JApplication imports all plugins from 'user' group, which triggers __constructors

基本上,使用插件的 __ constructor ,可以在下面设置类似这样的简单操作:

Basically, with plugin's __constructor one can set up simple action like this one below:

class plgUserAccountactivation extends JPlugin
{
    public function __construct(& $subject, $config)
    {
        parent::__construct($subject, $config);

        if(isset($_GET['emailactivation'])) {
            // check token
            // activate account, email or whatever
            // redirect with message
        }
    }
}

哇!它起作用了,不必创建整个控制器来处理一个简单的任务.

Wow! It works, it is not necessary to create a whole controller to handle one simple task.

但是请稍等...

  • 在链接中,将index.php?option = com_users更改为index.php?option = com_user
  • 让我们尝试Joomla 1.5 ...

嘿,嘿,什么都没有发生,com_user根本不导入任何东西,并且__constructor都不会被调用.

Hey, hey, nothing happens com_user didn't import anything at all and __constructor wan't called.

在Joomla 1.5中,我为此感到非常困扰,而且我不想编写整个组件.

I am very troubled by this in Joomla 1.5 and I don't feel like writing whole component.

如果有人有个好主意,请告诉我.

Should anybody have some bright idea, please let me know.

修改: 我已经通过以下形式发送链接解决了我的问题:

I've solved my problem by sending the link in the following form:

http:/example.com/index.php?option = com_user& task =注销& emailactivation = 1& u = 63& d077b8106 = 1

http:/example.com/index.php?option=com_user&task=logout&emailactivation=1&u=63&d077b8106=1

这样,将包括用户插件并执行__constructors.但这太轻描淡写了,因为 task = logout 并不真正鼓励您单击链接.

This way user plugins are included and __constructors are executed. But this is so frivolous as task=logout doesn't really encourage to click in the link.

推荐答案

1.5的问题是事件受到更多限制.您可以使用以下事件: Joomla 1.5插件事件-用户.我想因此您的插件未启动.

The problem with 1.5 is, that events are more limited. You have the following events available: Joomla 1.5 Plugin Events - User. I guess therefore your plugin is not initiated.

如何使它成为系统插件并检查URL/请求属性中的激活?像这样:

How about making this a system plugin and checking for the activation in the URL/request properties? Something like:

class plgSystemUseractiavation extends JPlugin {

  function onAfterInitialise(){

    $u = &JURI::getInstance(); 
    $option = trim(strtolower($u->getVar('option')));
    $emailactivation = trim(strtolower($u->getVar('emailactivation')));

    if( strlen($option  < 1) ){ // for SEF...
        $option = trim(strtolower(JRequest::getString('option')));
    }

    $app =& JFactory::getApplication(); 
    $appName = trim(strtolower($app->getName()));
    if( $appName === 'site' ){
        if( ( $option === 'com_users' ) || ( $option === 'com_user' ) ){
            if( $emailactivation === '1' ){
                // check token
                // activate account, email or whatever
                // redirect with message                        
            }
        }       
    }       
 }      
}

这篇关于Joomla 1.5 com_user并导入用户插件,例如Joomla 1.6及更高版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆