1

在 Joomla 3.0 中,基于 id 保护视图的最佳方法是什么。例如我有一个像这样的网址:

/administrator/index.php?option=com_helloworld&view=unitversions&layout=edit&id=158733

如果用户不“拥有”该 ID,我不希望他们能够看到此页面。我了解控制器将根据 ACL 进行授权,但只是重定向到与上述类似的 URL。

我在想一个插件可能是最好的方法?也许使用 onContentBeforeDisplay 触发器。

有人有更好的建议吗?

谢谢!

4

1 回答 1

2

我认为这可能是 CMS 核心文件中最好的方法。

    // Check for edit form.
    if ($vName == 'category' && $lName == 'edit' && !$this->checkEditId('com_categories.edit.category', $id))
    {
        // Somehow the person just went to the form - we don't allow that.
        $this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_UNHELD_ID', $id));
        $this->setMessage($this->getError(), 'error');
        $this->setRedirect(JRoute::_('index.php?option=com_categories&view=categories&extension='.$this->extension, false));

        return false;
    }
于 2013-05-22T17:43:26.480 回答