Joomla 1.5 com_user 并导入 Joomla 1.6 及更高版本等用户插件

发布于 2024-12-02 09:28:32 字数 1597 浏览 1 评论 0原文

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

好的。让我们变得更简单:

  1. 用户获取激活链接: http://example.com/index.php?option=com_users&task=edit&emailactivation=1&u=63&d077b8106=1 并单击它。
  2. 当然,该组件将省略 emailactivation 和其他参数,仅显示“编辑个人资料表单”(或访客登录表单)。
  3. 然后 JApplication 从“user”组导入所有插件,这会触发 __constructors

基本上,使用插件的 __constructor 可以设置如下所示的简单操作:

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?option=com_users 更改为index.php?option=com_user
  • 让我们尝试一下Joomla 1.5...

嘿嘿,没有任何反应com_user 根本没有导入任何内容并且 __constructor 不会被调用。

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

如果有人有什么好主意,请告诉我。

编辑: 我通过以下形式发送链接解决了我的问题:

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

这样就包含了用户插件并执行了 __constructors。但这太无聊了,因为 task=logout 并不真正鼓励点击链接。

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

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.

But hold on a minute...

  • In the link change index.php?option=com_users to index.php?option=com_user
  • And let's try on Joomla 1.5...

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

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.

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

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

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

少女净妖师 2024-12-09 09:28:32

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

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.

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                        
            }
        }       
    }       
 }      
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文