diff --git a/administrator/components/com_installer/controllers/update.php b/administrator/components/com_installer/controllers/update.php
index 37b2aaae7d3e4..94cdef43e966f 100644
--- a/administrator/components/com_installer/controllers/update.php
+++ b/administrator/components/com_installer/controllers/update.php
@@ -94,7 +94,11 @@ public function purge()
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
$model = $this->getModel('update');
$model->purge();
- $model->enableSites();
+
+ // We no longer need to enable update sites in Joomla! 3.4 as we now allow the users to manage update sites
+ // themselves.
+ // $model->enableSites();
+
$this->setRedirect(JRoute::_('index.php?option=com_installer&view=update', false), $model->_message);
}
diff --git a/administrator/components/com_installer/controllers/updatesites.php b/administrator/components/com_installer/controllers/updatesites.php
new file mode 100644
index 0000000000000..ab9fce36cb232
--- /dev/null
+++ b/administrator/components/com_installer/controllers/updatesites.php
@@ -0,0 +1,76 @@
+registerTask('unpublish', 'publish');
+ $this->registerTask('publish', 'publish');
+ }
+
+ /**
+ * Enable/Disable an extension (if supported).
+ *
+ * @return void
+ *
+ * @since 3.4
+ *
+ * @throws Exception on error
+ */
+ public function publish()
+ {
+ // Check for request forgeries.
+ JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
+
+ $ids = $this->input->get('cid', array(), 'array');
+ $values = array('publish' => 1, 'unpublish' => 0);
+ $task = $this->getTask();
+ $value = JArrayHelper::getValue($values, $task, 0, 'int');
+
+ if (empty($ids))
+ {
+ throw new Exception(JText::_('COM_INSTALLER_ERROR_NO_UPDATESITES_SELECTED'), 500);
+ }
+
+ // Get the model.
+ $model = $this->getModel('Updatesites');
+
+ // Change the state of the records.
+ if (!$model->publish($ids, $value))
+ {
+ throw new Exception(implode('
', $model->getErrors()), 500);
+ }
+
+ $ntext = ($value == 0) ? 'COM_INSTALLER_N_EXTENSIONS_UNPUBLISHED' : 'COM_INSTALLER_N_EXTENSIONS_PUBLISHED';
+
+ $this->setMessage(JText::plural($ntext, count($ids)));
+
+ $this->setRedirect(JRoute::_('index.php?option=com_installer&view=updatesites', false));
+ }
+}
diff --git a/administrator/components/com_installer/helpers/installer.php b/administrator/components/com_installer/helpers/installer.php
index 2a30c544f05b4..fa1dffaf5a5fc 100644
--- a/administrator/components/com_installer/helpers/installer.php
+++ b/administrator/components/com_installer/helpers/installer.php
@@ -62,6 +62,11 @@ public static function addSubmenu($vName = 'install')
'index.php?option=com_installer&view=languages',
$vName == 'languages'
);
+ JHtmlSidebar::addEntry(
+ JText::_('COM_INSTALLER_SUBMENU_UPDATESITES'),
+ 'index.php?option=com_installer&view=updatesites',
+ $vName == 'updatesites'
+ );
}
/**
diff --git a/administrator/components/com_installer/models/extension.php b/administrator/components/com_installer/models/extension.php
index ce653cb270f32..a731540c95e1e 100644
--- a/administrator/components/com_installer/models/extension.php
+++ b/administrator/components/com_installer/models/extension.php
@@ -103,7 +103,7 @@ protected function _getList($query, $limitstart = 0, $limit = 0)
*
* @return array The array of translated objects
*/
- private function translate(&$items)
+ protected function translate(&$items)
{
$lang = JFactory::getLanguage();
foreach ($items as &$item)
diff --git a/administrator/components/com_installer/models/update.php b/administrator/components/com_installer/models/update.php
index 17b7790f8345e..2f0e5df60fe45 100644
--- a/administrator/components/com_installer/models/update.php
+++ b/administrator/components/com_installer/models/update.php
@@ -177,12 +177,12 @@ public function purge()
->set($db->quoteName('last_check_timestamp') . ' = ' . $db->quote(0));
$db->setQuery($query);
$db->execute();
- $this->_message = JText::_('COM_INSTALLER_PURGED_UPDATES');
+ $this->_message = JText::_('JLIB_INSTALLER_PURGED_UPDATES');
return true;
}
else
{
- $this->_message = JText::_('COM_INSTALLER_FAILED_TO_PURGE_UPDATES');
+ $this->_message = JText::_('JLIB_INSTALLER_FAILED_TO_PURGE_UPDATES');
return false;
}
}
diff --git a/administrator/components/com_installer/models/updatesites.php b/administrator/components/com_installer/models/updatesites.php
new file mode 100644
index 0000000000000..c573973bbbf49
--- /dev/null
+++ b/administrator/components/com_installer/models/updatesites.php
@@ -0,0 +1,249 @@
+getUserStateFromRequest($this->context . '.filter.search', 'filter_search');
+ $this->setState('filter.search', $search);
+
+ $clientId = $this->getUserStateFromRequest($this->context . '.filter.client_id', 'filter_client_id', '');
+ $this->setState('filter.client_id', $clientId);
+
+ $status = $this->getUserStateFromRequest($this->context . '.filter.enabled', 'filter_enabled', '');
+ $this->setState('filter.enabled', $status);
+
+ $categoryId = $this->getUserStateFromRequest($this->context . '.filter.type', 'filter_type', '');
+ $this->setState('filter.type', $categoryId);
+
+ $group = $this->getUserStateFromRequest($this->context . '.filter.group', 'filter_group', '');
+ $this->setState('filter.group', $group);
+
+ parent::populateState('name', 'asc');
+ }
+
+ /**
+ * Enable/Disable an extension.
+ *
+ * @param array &$eid Extension ids to un/publish
+ * @param int $value Publish value
+ *
+ * @return boolean True on success
+ *
+ * @since 3.4
+ *
+ * @throws Exception on ACL error
+ */
+ public function publish(&$eid = array(), $value = 1)
+ {
+ $user = JFactory::getUser();
+
+ if (!$user->authorise('core.edit.state', 'com_installer'))
+ {
+ throw new Exception(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'), 403);
+ }
+
+ $result = true;
+
+ /*
+ * Ensure eid is an array of extension ids
+ */
+ if (!is_array($eid))
+ {
+ $eid = array($eid);
+ }
+
+ // Get a table object for the extension type
+ $table = JTable::getInstance('Updatesite');
+
+ // Enable the update site in the table and store it in the database
+ foreach ($eid as $i => $id)
+ {
+ $table->load($id);
+ $table->enabled = $value;
+
+ if (!$table->store())
+ {
+ $this->setError($table->getError());
+ $result = false;
+ }
+ }
+
+ return $result;
+ }
+
+ /**
+ * Method to get the database query
+ *
+ * @return JDatabaseQuery The database query
+ *
+ * @since 3.4
+ */
+ protected function getListQuery()
+ {
+ $enabled = $this->getState('filter.enabled');
+ $type = $this->getState('filter.type');
+ $client = $this->getState('filter.client_id');
+ $group = $this->getState('filter.group');
+
+ $query = JFactory::getDbo()->getQuery(true)
+ ->select(array(
+ 's.update_site_id',
+ 's.name as update_site_name',
+ 's.type as update_site_type',
+ 's.location',
+ 's.enabled',
+ 'e.extension_id',
+ 'e.name',
+ 'e.type',
+ 'e.element',
+ 'e.folder',
+ 'e.client_id',
+ 'e.state',
+ 'e.manifest_cache',
+ ))
+ ->from('#__update_sites AS s')
+ ->innerJoin('#__update_sites_extensions AS se on(se.update_site_id = s.update_site_id)')
+ ->innerJoin('#__extensions AS e ON(e.extension_id = se.extension_id)')
+ ->where('state=0');
+
+ if ($enabled != '')
+ {
+ $query->where('s.enabled=' . (int)$enabled);
+ }
+
+ if ($type)
+ {
+ $query->where('e.type=' . $this->_db->quote($type));
+ }
+
+ if ($client != '')
+ {
+ $query->where('client_id=' . (int)$client);
+ }
+
+ if ($group != '' && in_array($type, array('plugin', 'library', '')))
+ {
+ $query->where('folder=' . $this->_db->quote($group == '*' ? '' : $group));
+ }
+
+ // Filter by search in id
+ $search = $this->getState('filter.search');
+
+ if (!empty($search) && stripos($search, 'id:') === 0)
+ {
+ $query->where('s.update_site_id = ' . (int)substr($search, 3));
+ }
+
+ return $query;
+ }
+
+ /**
+ * Returns an object list
+ *
+ * @param string $query The query
+ * @param int $limitstart Offset
+ * @param int $limit The number of records
+ *
+ * @return array
+ */
+ protected function _getList($query, $limitstart = 0, $limit = 0)
+ {
+ $ordering = $this->getState('list.ordering');
+ $search = $this->getState('filter.search');
+
+ // Replace slashes so preg_match will work
+ $search = str_replace('/', ' ', $search);
+ $db = $this->getDbo();
+
+ if ($ordering == 'name' || (!empty($search) && stripos($search, 'id:') !== 0))
+ {
+ $db->setQuery($query);
+ $result = $db->loadObjectList();
+ $this->translate($result);
+
+ if (!empty($search) && (stripos($search, 'id:') !== 0))
+ {
+ foreach ($result as $i => $item)
+ {
+ if (!preg_match("/$search/i", $item->name) && !preg_match("/$search/i", $item->update_site_name))
+ {
+ unset($result[$i]);
+ }
+ }
+ }
+
+ JArrayHelper::sortObjects($result, $this->getState('list.ordering'), $this->getState('list.direction') == 'desc' ? -1 : 1, true, true);
+
+ $total = count($result);
+ $this->cache[$this->getStoreId('getTotal')] = $total;
+
+ if ($total < $limitstart)
+ {
+ $limitstart = 0;
+ $this->setState('list.start', 0);
+ }
+
+ return array_slice($result, $limitstart, $limit ? $limit : null);
+ }
+
+ $query->order($db->quoteName($ordering) . ' ' . $this->getState('list.direction'));
+ $result = parent::_getList($query, $limitstart, $limit);
+ $this->translate($result);
+
+ return $result;
+ }
+}
diff --git a/administrator/components/com_installer/views/update/view.html.php b/administrator/components/com_installer/views/update/view.html.php
index 120618af6a1e6..8ff79988e6dbd 100644
--- a/administrator/components/com_installer/views/update/view.html.php
+++ b/administrator/components/com_installer/views/update/view.html.php
@@ -80,6 +80,7 @@ protected function addToolbar()
{
JToolbarHelper::custom('update.update', 'upload', 'upload', 'COM_INSTALLER_TOOLBAR_UPDATE', true, false);
JToolbarHelper::custom('update.find', 'refresh', 'refresh', 'COM_INSTALLER_TOOLBAR_FIND_UPDATES', false, false);
+ JToolbarHelper::custom('update.purge', 'purge', 'purge', 'COM_INSTALLER_TOOLBAR_PURGE', false, false);
JToolbarHelper::divider();
JToolbarHelper::help('JHELP_EXTENSIONS_EXTENSION_MANAGER_UPDATE');
diff --git a/administrator/components/com_installer/views/updatesites/index.html b/administrator/components/com_installer/views/updatesites/index.html
new file mode 100644
index 0000000000000..2efb97f319a35
--- /dev/null
+++ b/administrator/components/com_installer/views/updatesites/index.html
@@ -0,0 +1 @@
+