Joomla 1.5 com_user和导入用户插件,如Joomla 1.6及以上


Joomla 1.5 com_user and importing user plugins like Joomla 1.6 and above

当访问Joomla 1.6和1.7中的com_users组件时,应用程序会自动从'user'组导入所有插件。显然,如果不想创建一个组件来简单地将一些变量传递给插件,那么它是非常有用的。

Ok。让我们简化一下:

  1. 用户获得一个激活链接:http://example.com/index.php?option=com_users&task=edit&emailactivation=1&u=63&d077b8106=1并点击它。
  2. 当然,该组件将省略email激活和其他参数,只是显示"编辑配置文件表单"(或客人登录表单)。然后JApplication从'user'组中导入所有插件,这会触发__constructors
基本上,使用插件的 __构造函数可以设置如下所示的简单操作:
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
        }
    }
}

哇!它可以工作,不需要创建一个完整的控制器来处理一个简单的任务。

请稍等…

  • 在链接更改index.php?选项=com_users to index.php?选择= com_user
  • 让我们试试Joomla 1.5…

嘿,嘿,什么都没发生com_user没有导入任何东西,__constructor也没有被调用。

在Joomla 1.5中,我对此感到非常困扰,我不想编写整个组件。

如果谁有什么好主意,请告诉我。 编辑:

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

http:/example.com/index.php ?选项= com_user& 任务=注销, emailactivation = 1, u = 63, d077b8106 = 1

这样包含用户插件并执行__构造函数。但是这太无聊了,因为task=logout并没有真正鼓励点击链接。

1.5的问题是,事件更有限。您有以下事件可用:Joomla 1.5插件事件-用户。我猜你的插件没有启动。

如何使这一个系统插件和检查激活的URL/请求属性?比如:

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                        
            }
        }       
    }       
 }      
}