10 defined(
'JPATH_PLATFORM') or die;
31 parent::__construct(
'#__extensions',
'extension_id', $db);
42 public function check()
45 if (trim($this->name) ==
'' || trim($this->element) ==
'')
47 $this->setError(
JText::_(
'JLIB_DATABASE_ERROR_MUSTCONTAIN_A_TITLE_EXTENSION'));
66 public function bind($array, $ignore =
'')
68 if (isset($array[
'params']) && is_array($array[
'params']))
72 $array[
'params'] = (string) $registry;
75 if (isset($array[
'control']) && is_array($array[
'control']))
79 $array[
'control'] = (string) $registry;
82 return parent::bind($array, $ignore);
94 public function find($options = array())
97 $query = $this->_db->getQuery(
true);
99 foreach ($options as $col => $val)
101 $query->where($col .
' = ' . $this->_db->quote($val));
104 $query->select($this->_db->quoteName(
'extension_id'))
105 ->from($this->_db->quoteName(
'#__extensions'));
106 $this->_db->setQuery($query);
108 return $this->_db->loadResult();
125 public function publish($pks = null, $state = 1, $userId = 0)
127 $k = $this->_tbl_key;
131 $userId = (int) $userId;
132 $state = (int) $state;
139 $pks = array($this->$k);
144 $this->setError(
JText::_(
'JLIB_DATABASE_ERROR_NO_ROWS_SELECTED'));
151 $where = $k .
'=' . implode(
' OR ' . $k .
'=', $pks);
154 if (!property_exists($this,
'checked_out') || !property_exists($this,
'checked_out_time'))
160 $checkin =
' AND (checked_out = 0 OR checked_out = ' . (int) $userId .
')';
164 $query = $this->_db->getQuery(
true)
165 ->update($this->_db->quoteName($this->_tbl))
166 ->
set($this->_db->quoteName(
'enabled') .
' = ' . (int) $state)
167 ->where(
'(' . $where .
')' . $checkin);
168 $this->_db->setQuery($query);
169 $this->_db->execute();
172 if ($checkin && (count($pks) == $this->_db->getAffectedRows()))
175 foreach ($pks as $pk)
182 if (in_array($this->$k, $pks))
184 $this->enabled = $state;