Source for file update.php
Documentation is available at update.php
* @package Joomla.Administrator
* @subpackage com_installer
* @copyright Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
* @package Joomla.Administrator
* @subpackage com_installer
* @param array $config An optional associative array of configuration settings.
if (empty($config['filter_fields']))
$config['filter_fields'] =
array(
* Method to auto-populate the model state.
* Note. Calling getState in this method will result in recursion.
* @param string $ordering An optional ordering field.
* @param string $direction An optional direction (asc|desc).
protected function populateState($ordering =
null, $direction =
null)
$value =
$app->getUserStateFromRequest($this->context .
'.filter.search', 'filter_search');
$this->setState('filter.search', $value);
$this->setState('filter.client_id', $clientId);
$this->setState('filter.type', $categoryId);
$this->setState('filter.group', $group);
$this->setState('message', $app->getUserState('com_installer.message'));
$this->setState('extension_message', $app->getUserState('com_installer.extension_message'));
$app->setUserState('com_installer.message', '');
$app->setUserState('com_installer.extension_message', '');
* Method to get the database query
* @return JDatabaseQuery The database query
$query =
$db->getQuery(true);
$client =
$this->getState('filter.client_id');
$group =
$this->getState('filter.group');
// Grab updates ignoring new installs
->where('extension_id != 0')
->order($this->getState('list.ordering') .
' ' .
$this->getState('list.direction'));
$query->where('type=' .
$db->quote($type));
$query->where('client_id = ' .
intval($client));
if ($group !=
'' &&
in_array($type, array('plugin', 'library', '')))
$query->where('folder=' .
$db->quote($group ==
'*' ?
'' :
$group));
// Filter by extension_id
if ($eid =
$this->getState('filter.extension_id'))
$query->where($db->quoteName('extension_id') .
' = ' .
$db->quote((int)
$eid));
$query->where($db->quoteName('extension_id') .
' != ' .
$db->quote(0))
->where($db->quoteName('extension_id') .
' != ' .
$db->quote(700));
$search =
$this->getState('filter.search');
$query->where('name LIKE ' .
$db->quote('%' .
$search .
'%'));
* Finds updates for an extension.
* @param int $eid Extension identifier to look for
* @param int $cache_timeout Cache timout
public function findUpdates($eid =
0, $cache_timeout =
0)
// Purge the updates list
$updater->findUpdates($eid, $cache_timeout);
* Removes all of the updates from the table.
* @return boolean result of operation
// Note: TRUNCATE is a DDL operation
// This may or may not mean depending on your database
$db->setQuery('TRUNCATE TABLE #__updates');
// Reset the last update check timestamp
$query =
$db->getQuery(true)
->update($db->quoteName('#__update_sites'))
->set($db->quoteName('last_check_timestamp') .
' = ' .
$db->quote(0));
$this->_message =
JText::_('COM_INSTALLER_PURGED_UPDATES');
$this->_message =
JText::_('COM_INSTALLER_FAILED_TO_PURGE_UPDATES');
* Enables any disabled rows in #__update_sites table
* @return boolean result of operation
$query =
$db->getQuery(true)
->update('#__update_sites')
if ($rows =
$db->getAffectedRows())
$this->_message .=
JText::plural('COM_INSTALLER_ENABLED_UPDATES', $rows);
$this->_message .=
JText::_('COM_INSTALLER_FAILED_TO_ENABLE_UPDATES');
* Sets the "result" state with the result of the operation.
* @param array $uids Array[int] List of updates to apply
$update->loadFromXML($instance->detailsurl);
// Install sets state and enqueues messages
$res =
$this->install($update);
$result =
$res & $result;
* Handles the actual update installation.
* @param JUpdate $update An update definition
* @return boolean Result of install
private function install($update)
if (isset
($update->get('downloadurl')->_data))
$url =
$update->downloadurl->_data;
// Was the package downloaded?
$tmp_dest =
$config->get('tmp_path');
// Unpack the downloaded package file
// Get an installer instance
$update->set('type', $package['type']);
if (!$installer->update($package['dir']))
// There was an error updating the package
// Package updated successfully
$this->type =
$package['type'];
// Set some model state values
$app->enqueueMessage($msg);
// TODO: Reconfigure this code when you have more battery life left
$this->setState('name', $installer->get('name'));
$app->setUserState('com_installer.message', $installer->message);
$app->setUserState('com_installer.extension_message', $installer->get('extension_message'));
// Cleanup the install files
if (!is_file($package['packagefile']))
$package['packagefile'] =
$config->get('tmp_path') .
'/' .
$package['packagefile'];
* Method to get the row form.
* @param array $data Data for the form.
* @param boolean $loadData True if the form is to load its own data (default case), false if not.
* @return mixed A JForm object on success, false on failure
public function getForm($data =
array(), $loadData =
true)
$form =
JForm::getInstance('com_installer.update', 'update', array('load_data' =>
$loadData));
// Check the session for previously entered form data.
// Bind the form data if present.
* Method to get the data that should be injected in the form.
* @return mixed The data for the form.
// Check the session for previously entered form data.
Documentation generated on Tue, 19 Nov 2013 15:16:10 +0100 by phpDocumentor 1.4.3