2

我正在 Joomla 中创建一个组件!1.7,我想利用框架的签出/签入功能。目前

  • 当用户请求对该记录进行编辑任务时,如何将组件记录标记为“已签出”?
  • 当用户尝试存储他或她的编辑时,如何将记录标记为“已签入”?
  • 如何在编辑时测试组件记录的签入/签出状态?

谢谢!

4

1 回答 1

4

基本上,您的模型中需要两个方法,您可以随时调用它们:

function checkin()
{
    if ($this->_id)
    {
        $item= & $this->getTable();
        if(! $item->checkin($this->_id)) {
            $this->setError($this->_db->getErrorMsg());
            return false;
        }
    }
    return false;
}

function checkout($uid = null)
{
    if ($this->_id)
    {
        // Make sure we have a user id to checkout the article with
        if (is_null($uid)) {
            $user   =& JFactory::getUser();
            $uid    = $user->get('id');
        }
        // Lets get to it and checkout the thing...
        $item= & $this->getTable();
        if(!$item->checkout($uid, $this->_id)) {
            $this->setError($this->_db->getErrorMsg());
            return false;
        }

        return true;
    }
    return false;
}

要将项目标记为已检查,首先您必须checked_out使用默认值 0 调用列,还需要checked_out_time存储项目被检出的时间。希望能帮助到你。

于 2011-12-06T07:37:44.343 回答