API16

JTable/isCheckedOut

From Joomla! Documentation

< API16:JTable

The "API16" namespace is an archived namespace. This page contains information for a Joomla! version which is no longer supported. It exists only as a historical reference, it will not be improved and its content may be incomplete and/or contain broken links.

Description[edit]

TODO: This either needs to be static or not.



Syntax[edit]

isCheckedOut($with=0, $against=null)
Parameter Name Default Value Description
$with 0 The userid to preform the match with, if an item is checked out by this user the function will return false.
$against null The userid to perform the match against when the function is used as a static function.

Returns[edit]

boolean True if checked out.

Defined in[edit]

libraries/joomla/database/table.php

Importing[edit]

jimport( 'joomla.database.table' );

Source Body[edit]

public function isCheckedOut($with = 0, $against = null)
{
        // Handle the non-static case.
        if (isset($this) && ($this instanceof JTable) && is_null($against)) {
                $against = $this->get('checked_out');
        }

        // The item is not checked out or is checked out by the same user.
        if (!$against || ($against == $with)) {
                return false;
        }

        $db = JFactory::getDBO();
        $db->setQuery(
                'SELECT COUNT(userid)' .
                ' FROM `#__session`' .
                ' WHERE `userid` = '.(int) $against
        );
        $checkedOut = (boolean) $db->loadResult();

        // If a session exists for the user then it is checked out.
        return $checkedOut;
}



Examples[edit]

Code Examples[edit]