Exemplo n.º 1
0
 /**
  * Is a record locked?
  *
  * @param   integer $with            The userid to preform the match with. If an item is checked
  *                                   out by this user the function will return false.
  * @param   integer $unused_against  Junk inherited from JTable; ignore
  *
  * @throws  UnexpectedValueException
  *
  * @return  boolean  True if the record is locked by another user
  */
 public function isCheckedOut($with = 0, $unused_against = null)
 {
     $against = null;
     $fldLockedBy = $this->getColumnAlias('locked_by');
     $k = $this->_tbl_key;
     // If no primary key is given, return false.
     if ($this->{$k} === null) {
         throw new UnexpectedValueException('Null primary key not allowed.');
     }
     if (isset($this) && is_a($this, 'FOFTable') && !$against) {
         $against = $this->get($fldLockedBy);
     }
     // Item is not checked out, or being checked out by the same user
     if (!$against || $against == $with) {
         return false;
     }
     $query = $this->_db->getQuery(true)->select('COUNT(userid)')->from($this->_db->quoteName('#__session'))->where($this->_db->quoteName('userid') . ' = ' . $this->_db->quote($against));
     $this->_db->setQuery($query);
     if (!($result = $this->_db->loadResult())) {
         $this->setError($this->_db->stderr());
         return false;
     }
     return (bool) $result;
 }