【问题标题】:automatic append subgroups joomla自动附加子组 joomla
【发布时间】:2014-03-09 19:41:13
【问题描述】:

我最近开始在 Joomla (3.x) 中制作自己的组件。 现在我正在尝试自动将子组附加到新用户组。

我想要的是以下内容: --> 当我创建一个新的用户组 A 时,我想自动将子组 B、子组 C 和子组 D 添加到用户组 A。(类似于OnAfterSave?)

/libraries/joomla/table/usergroup.php 中,我找到了一个为我重建lftrgt 值的函数。也许我可以用它做点什么? 还是我应该自己构建查询?

而且我不知道在哪里构建自制的onAfterSave 函数,这使得子组......

我希望有人能帮我解决这个问题吗? 提前致谢!

【问题讨论】:

    标签: php joomla components usergroups


    【解决方案1】:

    OnAfterXXXXSave() 是由特定区域 plugins 处理的 Joomla 事件。

    你可以写一个插件来回复standard Joomla events或者你可以add support for plugins to a component你写的。

    正如您从该列表中看到的那样,没有与 com_categories 关联的事件,但是在探索 /administrator/com_categories 目录时,我可以看到 category.phpCategoriesModelCategorysave() 中触发 onContentBeforeSave()onContentAfterSave() (即models/category.php)。

    class CategoriesModelCategory extends JModelAdmin
    {
    :
        public function save($data)
        {
            $dispatcher = JEventDispatcher::getInstance();
        :
        // Trigger the onContentBeforeSave event.
        $result = $dispatcher->trigger($this->event_before_save, array($this->option . '.' . $this->name, &$table, $isNew));
        :
        :
        // Trigger the onContentAfterSave event.
        $dispatcher->trigger($this->event_after_save, array($this->option . '.' . $this->name, &$table, $isNew));
    

    基于此,我将从content plugin (tutorial) 开始,并根据您的用例对其进行调整。

    【讨论】:

    • 谢谢,这行得通。我找到了 onUserAfterSaveGroup($context, $row, $isNew) 方法。使用这种方法,我能够创建一个插件,自动将子组添加到我新添加的用户组中。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-07-19
    • 2013-09-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-15
    • 1970-01-01
    相关资源
    最近更新 更多