JTable/isCheckedOut: Difference between revisions
From Joomla! Documentation
New page: ===Description===
TODO: This either needs to be static or not.
<span class="editsection" style="font-size:76%;">
<nowiki>[</nowiki>Edit Descripton<... |
m preparing for archive only |
||
| (One intermediate revision by the same user not shown) | |||
| Line 2: | Line 2: | ||
TODO: This either needs to be static or not. | TODO: This either needs to be static or not. | ||
===Syntax=== | ===Syntax=== | ||
| Line 61: | Line 59: | ||
</source> | </source> | ||
===Examples=== | ===Examples=== | ||
=== Code Examples === | |||
<dpl> | <dpl> | ||
noresultsheader=\n | noresultsheader=\n | ||
category=isCheckedOut | category=isCheckedOut | ||
category=JTable | category=JTable | ||
namespace=CodeExample | |||
category=MethodExample | category=MethodExample | ||
include=* | include=* | ||
format= ,,, | format= ,,, | ||
</dpl> | </dpl> | ||
Latest revision as of 02:09, 25 March 2017
Description
TODO: This either needs to be static or not.
Syntax
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
boolean True if checked out.
Defined in
libraries/joomla/database/table.php
Importing
jimport( 'joomla.database.table' );
Source Body
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
Code Examples