29
0
mirror of https://github.com/joomla/joomla-cms.git synced 2024-06-27 07:33:41 +00:00

[#22158] Templates are still available for assignment after being unpublished

git-svn-id: http://joomlacode.org/svn/joomla/development/trunk@21650 6f6e1ebd-4c2b-0410-823f-f34bde69bce9
This commit is contained in:
Christophe Demko 2011-06-23 05:29:17 +00:00
parent 151e6f9cd1
commit f216953ca0
12 changed files with 75 additions and 44 deletions

View File

@ -85,7 +85,7 @@ class InstallerModelManage extends InstallerModel
* @return boolean True on success
* @since 1.5
*/
function publish($eid = array(), $value = 1)
function publish(&$eid = array(), $value = 1)
{
// Initialise variables.
$user = JFactory::getUser();
@ -105,10 +105,18 @@ class InstallerModelManage extends InstallerModel
// Get a table object for the extension type
$table = JTable::getInstance('Extension');
JTable::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_templates/tables');
// Enable the extension in the table and store it in the database
foreach($eid as $id) {
foreach($eid as $i=>$id) {
$table->load($id);
if ($table->type == 'template') {
$style = JTable::getInstance('Style', 'TemplatesTable');
if ($style->load(array('template' => $table->element, 'client_id' => $table->client_id, 'home'=>1))) {
JError::raiseNotice(403, JText::_('COM_INSTALLER_ERROR_DISABLE_DEFAULT_TEMPLATE_NOT_PERMITTED'));
unset($eid[$i]);
continue;
}
}
$table->enabled = $value;
if (!$table->store()) {
$this->setError($table->getError());

View File

@ -142,10 +142,14 @@ abstract class ModulesHelper
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('DISTINCT(m.module) AS value, e.name AS text');
$query->from('#__modules AS m');
$query->join('LEFT', '#__extensions AS e ON e.element=m.module');
$query->where('m.`client_id` = '.(int)$clientId);
$query->select('element AS value, name AS text');
$query->from('#__extensions as e');
$query->where('e.`client_id` = '.(int)$clientId);
$query->where('`type` = '.$db->quote('module'));
$query->where('`enabled` = 1');
$query->leftJoin('#__modules as m ON m.module=e.element AND m.client_id=e.client_id');
$query->where('m.module IS NOT NULL');
$query->group('element');
$db->setQuery($query);
$modules = $db->loadObjectList();

View File

@ -81,19 +81,19 @@ class TemplatesHelper
{
// Build the filter options.
$db = JFactory::getDbo();
$query = $db->getQuery(true);
if ($clientId == '*') {
$where = '';
} else {
$where = ' WHERE client_id = '.(int) $clientId;
if ($clientId != '*') {
$query->where('client_id='.(int) $clientId);
}
$db->setQuery(
'SELECT DISTINCT(template) AS value, template AS text' .
' FROM #__template_styles' .
$where .
' ORDER BY template'
);
$query->select('element as value, name as text');
$query->from('#__extensions');
$query->where('type='.$db->quote('template'));
$query->where('enabled=1');
$query->order('client_id');
$query->order('name');
$db->setQuery($query);
$options = $db->loadObjectList();
return $options;
}
@ -119,4 +119,4 @@ class TemplatesHelper
return $data;
}
}
}

View File

@ -355,6 +355,13 @@ class TemplatesModelStyle extends JModelAdmin
*/
public function save($data)
{
// Detect disabled extension
$extension = JTable::getInstance('Extension');
if ($extension->load(array('enabled' => 0, 'type' => 'template', 'element' => $data['template'], 'client_id' => $data['client_id']))) {
$this->setError(JText::_('COM_TEMPLATES_ERROR_SAVE_DISABLED_TEMPLATE'));
return false;
}
// Initialise variables;
$dispatcher = JDispatcher::getInstance();
$table = $this->getTable();
@ -475,26 +482,23 @@ class TemplatesModelStyle extends JModelAdmin
throw new Exception(JText::_('JLIB_APPLICATION_ERROR_EDITSTATE_NOT_PERMITTED'));
}
// Lookup the client_id.
$db->setQuery(
'SELECT client_id' .
' FROM #__template_styles' .
' WHERE id = '.(int) $id
);
$clientId = $db->loadResult();
if ($error = $db->getErrorMsg()) {
throw new Exception($error);
}
else if (!is_numeric($clientId)) {
$style = JTable::getInstance('Style','TemplatesTable');
if (!$style->load((int)$id)) {
throw new Exception(JText::_('COM_TEMPLATES_ERROR_STYLE_NOT_FOUND'));
}
// Detect disabled extension
$extension = JTable::getInstance('Extension');
if ($extension->load(array('enabled' => 0, 'type' => 'template', 'element' => $style->template, 'client_id' => $style->client_id))) {
throw new Exception(JText::_('COM_TEMPLATES_ERROR_SAVE_DISABLED_TEMPLATE'));
}
// Reset the home fields for the client_id.
$db->setQuery(
'UPDATE #__template_styles' .
' SET home = \'0\'' .
' WHERE client_id = '.(int) $clientId .
' WHERE client_id = '.(int) $style->client_id .
' AND home = \'1\''
);

View File

@ -120,6 +120,10 @@ class TemplatesModelStyles extends JModelList
// Join over the language
$query->join('LEFT', '`#__languages` AS l ON l.lang_code = a.home');
// Filter by extension enabled
$query->join('LEFT', '`#__extensions` AS e ON e.element = a.template');
$query->where('e.enabled = 1');
// Filter by template.
if ($template = $this->getState('filter.template')) {
$query->where('a.template = '.$db->quote($template));

View File

@ -261,17 +261,15 @@ class JAdministrator extends JApplication
// Load the template name from the database
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('template, params');
$query->from('#__template_styles');
$query->where('client_id = 1');
$query->select('template, s.params');
$query->from('#__template_styles as s');
$query->leftJoin('#__extensions as e ON e.type='.$db->quote('template').' AND e.element=s.template AND e.client_id=s.client_id');
if ($admin_style)
{
$query->where('id = '.(int)$admin_style);
}
else
{
$query->where('home = 1');
$query->where('s.client_id = 1 AND id = '.(int)$admin_style. ' AND e.enabled = 1','OR');
}
$query->where('s.client_id = 1 AND home = 1','OR');
$query->order('home');
$db->setQuery($query);
$template = $db->loadObject();

View File

@ -3,12 +3,12 @@
; Copyright (C) 2005 - 2011 Open Source Matters. All rights reserved.
; License GNU General Public License version 2 or later; see LICENSE.txt, see LICENSE.php
; Note : All ini files need to be saved as UTF-8
COM_INSTALLER="Installation Manager"
COM_INSTALLER_AUTHOR_INFORMATION="Author Information"
COM_INSTALLER_CONFIGURATION="Installer configuration"
COM_INSTALLER_ENABLED_UPDATES_1=", 1 disabled site was enabled"
COM_INSTALLER_ENABLED_UPDATES_MORE=", %s disabled sites were enabled"
COM_INSTALLER_ERROR_DISABLE_DEFAULT_TEMPLATE_NOT_PERMITTED="Disable default template is not permitted"
COM_INSTALLER_ERROR_METHOD="Method Not Implemented"
COM_INSTALLER_ERROR_NO_EXTENSIONS_SELECTED="No extensions selected"
COM_INSTALLER_EXTENSION_PUBLISHED="Extension successfully enabled."

View File

@ -20,6 +20,7 @@ COM_TEMPLATES_ERROR_CANNOT_UNSET_DEFAULT_STYLE="Cannot unset default style"
COM_TEMPLATES_ERROR_EDITOR_DISABLED="Either the CodeMirror or the None editor plug-in should be enabled to edit template files"
COM_TEMPLATES_ERROR_EXTENSION_RECORD_NOT_FOUND="Extension record not found in database"
COM_TEMPLATES_ERROR_FAILED_TO_SAVE_FILENAME="An error occurred. The file %s could not be saved."
COM_TEMPLATES_ERROR_SAVE_DISABLED_TEMPLATE="Unable to save a style associated to a disabled template"
COM_TEMPLATES_ERROR_SOURCE_FILE_NOT_FOUND="Source file not found"
COM_TEMPLATES_ERROR_SOURCE_FILE_NOT_UNWRITABLE="Source file can't be returned to unwritable status"
COM_TEMPLATES_ERROR_SOURCE_FILE_NOT_WRITABLE="Source file not writable"

View File

@ -435,9 +435,11 @@ final class JSite extends JApplication
// Load styles
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select('id, home, template, params');
$query->from('#__template_styles');
$query->where('client_id = 0');
$query->select('id, home, template, s.params');
$query->from('#__template_styles as s');
$query->where('s.client_id = 0');
$query->where('e.enabled = 1');
$query->leftJoin('#__extensions as e ON e.element=s.template AND e.type='.$db->quote('template').' AND e.client_id=s.client_id');
$db->setQuery($query);
$templates = $db->loadObjectList('id');
@ -454,7 +456,12 @@ final class JSite extends JApplication
$cache->store($templates, 'templates0'.$tag);
}
$template = $templates[$id];
if (isset($templates[$id])) {
$template = $templates[$id];
}
else {
$template = $templates[0];
}
// Allows for overriding the active template from the request
$template->template = JRequest::getCmd('template', $template->template);

View File

@ -29,6 +29,7 @@ $ -> Language fix or change
23-Jun-2011 Christophe Demko
# [#24662] Newly published articles showing pending when they are actually published (revived) (Elin Waring)
# [#22158] Templates are still available for assignment after being unpublished
22-Jun-2011 Christophe Demko
# [#24604] JDate class sets php timezone to UTC which forces all Joomla addons to use UTC dates

View File

@ -292,6 +292,9 @@ abstract class JModuleHelper
$query->join('LEFT','#__menu AS mn ON mm.menuid = mn.id');
$query->where('m.published = 1');
$query->join('LEFT','#__extensions AS e ON e.element = m.module AND e.client_id = m.client_id');
$query->where('e.enabled = 1');
$date = JFactory::getDate();
$now = $date->toMySQL();
$nullDate = $db->getNullDate();

View File

@ -64,6 +64,7 @@ class JFormFieldTemplateStyle extends JFormFieldGroupedList
$query->where('s.template = '.$db->quote($template));
}
$query->join('LEFT', '#__extensions as e on e.element=s.template');
$query->where('e.enabled=1');
// Set the query and load the styles.
$db->setQuery($query);