Skip to content

Commit

Permalink
Merge branch '4.0-dev' into j4finder_commonwords
Browse files Browse the repository at this point in the history
  • Loading branch information
Hackwar committed Jun 26, 2018
2 parents 753788e + cc2eac1 commit 77564bb
Show file tree
Hide file tree
Showing 149 changed files with 2,732 additions and 1,199 deletions.
5 changes: 5 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Expand Up @@ -58,3 +58,8 @@ travis-phpunit.xml @mbabker @rdeutz

# Core JS
media/*/js/* @dgt41

# CSP Tooling
plugins/system/httpheaders/* @zero-24
administrator/components/com_csp/* @zero-24
components/com_csp/* @zero-24
1 change: 1 addition & 0 deletions administrator/components/com_admin/forms/profile.xml
Expand Up @@ -97,6 +97,7 @@
type="templatestyle"
label="COM_ADMIN_USER_FIELD_BACKEND_TEMPLATE_LABEL"
client="administrator"
filter="uint"
>
<option value="">JOPTION_USE_DEFAULT</option>
</field>
Expand Down
1 change: 1 addition & 0 deletions administrator/components/com_admin/script.php
Expand Up @@ -3974,6 +3974,7 @@ public function updateAssets($installer)
{
// List all components added since 4.0
$newComponents = array(
'com_csp',
);

foreach ($newComponents as $component)
Expand Down
@@ -1,5 +1,5 @@
INSERT INTO `#__extensions` (`extension_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `custom_data`, `system_data`, `checked_out`, `checked_out_time`, `ordering`, `state`) VALUES
(487, 'plg_system_httpheaders', 'plugin', 'httpheaders', 'system', 0, 0, 1, 0, '', '{}', '', '', 0, '0000-00-00 00:00:00', 0, 0);
INSERT INTO `#__extensions` (`extension_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `checked_out`, `checked_out_time`, `ordering`, `state`) VALUES
(487, 'plg_system_httpheaders', 'plugin', 'httpheaders', 'system', 0, 0, 1, 0, '', '{}', 0, '0000-00-00 00:00:00', 0, 0);

INSERT INTO `#__postinstall_messages` (`extension_id`, `title_key`, `description_key`, `action_key`, `language_extension`, `language_client_id`, `type`, `action_file`, `action`, `condition_file`, `condition_method`, `version_introduced`, `enabled`)
VALUES
Expand Down
@@ -0,0 +1,17 @@
--
-- Table structure for table `#__csp`
--

CREATE TABLE IF NOT EXISTS `#__csp` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`document_uri` varchar(500) NOT NULL DEFAULT '',
`blocked_uri` varchar(500) NOT NULL DEFAULT '',
`directive` varchar(500) NOT NULL DEFAULT '',
`created` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`modified` datetime NOT NULL DEFAULT '0000-00-00 00:00:00',
`published` tinyint(1) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 DEFAULT COLLATE=utf8mb4_unicode_ci;

INSERT INTO `#__extensions` (`extension_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `custom_data`, `system_data`, `checked_out`, `checked_out_time`, `ordering`, `state`, `namespace`) VALUES
(35, 'com_csp', 'component', 'com_csp', '', 0, 0, 1, 0, '', '{}', '', '', 0, '0000-00-00 00:00:00', 0, 0, 'Joomla\\Component\\Csp');
@@ -1,4 +1,4 @@
INSERT INTO `#__extensions`
(`extension_id`, `package_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `custom_data`, `system_data`, `checked_out`, `checked_out_time`, `ordering`, `state`)
(`extension_id`, `package_id`, `name`, `type`, `element`, `folder`, `client_id`, `enabled`, `access`, `protected`, `manifest_cache`, `params`, `checked_out`, `checked_out_time`, `ordering`, `state`)
VALUES
(488, 0, 'plg_sampledata_multilang', 'plugin', 'multilang', 'sampledata', 0, 0, 1, 0, '', '', '', '', 0, '0000-00-00 00:00:00', 0, 0);
(488, 0, 'plg_sampledata_multilang', 'plugin', 'multilang', 'sampledata', 0, 0, 1, 0, '', '', 0, '0000-00-00 00:00:00', 0, 0);
@@ -0,0 +1,17 @@
--
-- Table structure for table `#__csp`
--

CREATE TABLE IF NOT EXISTS "#__csp" (
"id" int(11) NOT NULL AUTO_INCREMENT,
"document_uri" varchar(500) NOT NULL DEFAULT '',
"blocked_uri" varchar(500) NOT NULL DEFAULT '',
"directive" varchar(500) NOT NULL DEFAULT '',
"created" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL,
"modified" timestamp without time zone DEFAULT '1970-01-01 00:00:00' NOT NULL,
"published" smallint DEFAULT 0 NOT NULL,
PRIMARY KEY ("id")
);

INSERT INTO "#__extensions" ("extension_id", "name", "type", "element", "folder", "client_id", "enabled", "access", "protected", "manifest_cache", "params", "custom_data", "system_data", "checked_out", "checked_out_time", "ordering", "state", "namespace") VALUES
(35, 'com_csp', 'component', 'com_csp', ' ', 0, 0, 1, 0, '', '{}', '', '', 0, '1970-01-01 00:00:00', 0, 0, 'Joomla\\Component\\Csp');
Expand Up @@ -83,7 +83,7 @@ protected function getOptions()
$itemId = (int) $associations[$language->lang_code]['id'];
$options[$langCode]->value = $language->lang_code . ':' . $itemId . ':edit';

// Check if user does have permission to edit the associated item.
// Check if user does have permission to edit the associated item.
$canEdit = AssociationsHelper::allowEdit($extensionName, $typeName, $itemId);

// Check if item can be checked out
Expand Down
Expand Up @@ -69,11 +69,11 @@ protected function getInput()

// Clear association button
$html[] = '<button'
. ' class="btn btn-secondary' . ($value ? '' : ' hidden') . '"'
. ' onclick="return Joomla.submitbutton(\'undo-association\');"'
. ' id="remove-assoc">'
. '<span class="icon-remove" aria-hidden="true"></span> ' . \JText::_('JCLEAR')
. '</button>';
. ' class="btn btn-secondary' . ($value ? '' : ' hidden') . '"'
. ' onclick="return Joomla.submitbutton(\'undo-association\');"'
. ' id="remove-assoc">'
. '<span class="icon-remove" aria-hidden="true"></span> ' . \JText::_('JCLEAR')
. '</button>';

$html[] = '<input type="hidden" id="' . $this->id . '_id" name="' . $this->name . '" value="' . $value . '">';

Expand Down
Expand Up @@ -38,8 +38,8 @@
JFactory::getDocument()->addScriptOptions('assosiations-modal', ['func' => $function]);
JHtml::_('script', 'com_associations/admin-associations-modal.min.js', false, true);
?>
<form action="<?php echo JRoute::_('index.php?option=com_associations&view=associations&layout=modal&tmpl=component&function=' . $function . '&' . JSession::getFormToken() . '=1');
?>" method="post" name="adminForm" id="adminForm">
<form action="<?php echo JRoute::_('index.php?option=com_associations&view=associations&layout=modal&tmpl=component&function='
. $function . '&' . JSession::getFormToken() . '=1'); ?>" method="post" name="adminForm" id="adminForm">

<?php if (!empty( $this->sidebar)) : ?>
<div id="j-sidebar-container" class="col-md-2">
Expand Down
40 changes: 20 additions & 20 deletions administrator/components/com_categories/tmpl/categories/default.php
Expand Up @@ -81,33 +81,33 @@
<?php if (isset($this->items[0]) && property_exists($this->items[0], 'count_published')) :
$columns++; ?>
<th style="width:3%" class="nowrap text-center d-none d-md-table-cell">
<span class="icon-publish hasTooltip" aria-hidden="true" title="<?php echo JText::_('COM_CATEGORY_COUNT_PUBLISHED_ITEMS'); ?>">
<span class="sr-only"><?php echo JText::_('COM_CATEGORY_COUNT_PUBLISHED_ITEMS'); ?></span>
</span>
<span class="icon-publish hasTooltip" aria-hidden="true" title="<?php echo JText::_('COM_CATEGORY_COUNT_PUBLISHED_ITEMS'); ?>">
<span class="sr-only"><?php echo JText::_('COM_CATEGORY_COUNT_PUBLISHED_ITEMS'); ?></span>
</span>
</th>
<?php endif; ?>
<?php if (isset($this->items[0]) && property_exists($this->items[0], 'count_unpublished')) :
$columns++; ?>
<th style="width:3%" class="nowrap text-center d-none d-md-table-cell">
<span class="icon-unpublish hasTooltip" aria-hidden="true" title="<?php echo JText::_('COM_CATEGORY_COUNT_UNPUBLISHED_ITEMS'); ?>">
<span class="sr-only"><?php echo JText::_('COM_CATEGORY_COUNT_UNPUBLISHED_ITEMS'); ?></span>
</span>
<span class="icon-unpublish hasTooltip" aria-hidden="true" title="<?php echo JText::_('COM_CATEGORY_COUNT_UNPUBLISHED_ITEMS'); ?>">
<span class="sr-only"><?php echo JText::_('COM_CATEGORY_COUNT_UNPUBLISHED_ITEMS'); ?></span>
</span>
</th>
<?php endif; ?>
<?php if (isset($this->items[0]) && property_exists($this->items[0], 'count_archived')) :
$columns++; ?>
<th style="width:3%" class="nowrap text-center d-none d-md-table-cell">
<span class="icon-archive hasTooltip" aria-hidden="true" title="<?php echo JText::_('COM_CATEGORY_COUNT_ARCHIVED_ITEMS'); ?>">
<span class="sr-only"><?php echo JText::_('COM_CATEGORY_COUNT_ARCHIVED_ITEMS'); ?></span>
</span>
<span class="icon-archive hasTooltip" aria-hidden="true" title="<?php echo JText::_('COM_CATEGORY_COUNT_ARCHIVED_ITEMS'); ?>">
<span class="sr-only"><?php echo JText::_('COM_CATEGORY_COUNT_ARCHIVED_ITEMS'); ?></span>
</span>
</th>
<?php endif; ?>
<?php if (isset($this->items[0]) && property_exists($this->items[0], 'count_trashed')) :
$columns++; ?>
<th style="width:3%" class="nowrap text-center d-none d-md-table-cell">
<span class="icon-trash hasTooltip" aria-hidden="true" title="<?php echo JText::_('COM_CATEGORY_COUNT_TRASHED_ITEMS'); ?>">
<span class="sr-only"><?php echo JText::_('COM_CATEGORY_COUNT_TRASHED_ITEMS'); ?></span>
</span>
<span class="icon-trash hasTooltip" aria-hidden="true" title="<?php echo JText::_('COM_CATEGORY_COUNT_TRASHED_ITEMS'); ?>">
<span class="sr-only"><?php echo JText::_('COM_CATEGORY_COUNT_TRASHED_ITEMS'); ?></span>
</span>
</th>
<?php endif; ?>
<th style="width:10%" class="nowrap d-none d-md-table-cell text-center">
Expand Down Expand Up @@ -271,14 +271,14 @@
&& $user->authorise('core.edit', $extension)
&& $user->authorise('core.edit.state', $extension)) : ?>
<?php echo JHtml::_(
'bootstrap.renderModal',
'collapseModal',
array(
'title' => JText::_('COM_CATEGORIES_BATCH_OPTIONS'),
'footer' => $this->loadTemplate('batch_footer'),
),
$this->loadTemplate('batch_body')
); ?>
'bootstrap.renderModal',
'collapseModal',
array(
'title' => JText::_('COM_CATEGORIES_BATCH_OPTIONS'),
'footer' => $this->loadTemplate('batch_footer'),
),
$this->loadTemplate('batch_body')
); ?>
<?php endif; ?>
<?php endif; ?>

Expand Down
133 changes: 133 additions & 0 deletions administrator/components/com_content/Model/ArticleModel.php
Expand Up @@ -68,6 +68,12 @@ protected function batchCopy($value, $pks, $contexts)
return false;
}

JPluginHelper::importPlugin('system');
$dispatcher = JEventDispatcher::getInstance();

// Register FieldsHelper
JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php');

// Parent exists so we let's proceed
while (!empty($pks))
{
Expand All @@ -94,6 +100,19 @@ protected function batchCopy($value, $pks, $contexts)
}
}

$fields = FieldsHelper::getFields('com_content.article', $this->table, true);
$fieldsData = array();

if (!empty($fields))
{
$fieldsData['com_fields'] = array();

foreach ($fields as $field)
{
$fieldsData['com_fields'][$field->name] = $field->rawvalue;
}
}

// Alter the title & alias
$data = $this->generateNewTitle($categoryId, $this->table->alias, $this->table->title);
$this->table->title = $data['0'];
Expand Down Expand Up @@ -149,6 +168,9 @@ protected function batchCopy($value, $pks, $contexts)
$db->setQuery($query);
$db->execute();
}

// Run event for copied article
$dispatcher->trigger('onContentAfterSave', array('com_content.article', &$this->table, true, $fieldsData));
}

// Clean the cache
Expand All @@ -157,6 +179,117 @@ protected function batchCopy($value, $pks, $contexts)
return $newIds;
}

/**
* Batch move categories to a new category.
*
* @param integer $value The new category ID.
* @param array $pks An array of row IDs.
* @param array $contexts An array of item contexts.
*
* @return boolean True on success.
*
* @since __DEPLOY_VERSION__
*/
protected function batchMove($value, $pks, $contexts)
{
if (empty($this->batchSet))
{
// Set some needed variables.
$this->user = JFactory::getUser();
$this->table = $this->getTable();
$this->tableClassName = get_class($this->table);
$this->contentType = new JUcmType;
$this->type = $this->contentType->getTypeByTable($this->tableClassName);
}

$categoryId = (int) $value;

if (!$this->checkCategoryId($categoryId))
{
return false;
}

JPluginHelper::importPlugin('system');
$dispatcher = JEventDispatcher::getInstance();

// Register FieldsHelper
JLoader::register('FieldsHelper', JPATH_ADMINISTRATOR . '/components/com_fields/helpers/fields.php');

// Parent exists so we proceed
foreach ($pks as $pk)
{
if (!$this->user->authorise('core.edit', $contexts[$pk]))
{
$this->setError(JText::_('JLIB_APPLICATION_ERROR_BATCH_CANNOT_EDIT'));

return false;
}

// Check that the row actually exists
if (!$this->table->load($pk))
{
if ($error = $this->table->getError())
{
// Fatal error
$this->setError($error);

return false;
}
else
{
// Not fatal error
$this->setError(JText::sprintf('JLIB_APPLICATION_ERROR_BATCH_MOVE_ROW_NOT_FOUND', $pk));
continue;
}
}

$fields = FieldsHelper::getFields('com_content.article', $this->table, true);
$fieldsData = array();

if (!empty($fields))
{
$fieldsData['com_fields'] = array();

foreach ($fields as $field)
{
$fieldsData['com_fields'][$field->name] = $field->rawvalue;
}
}

// Set the new category ID
$this->table->catid = $categoryId;

// Check the row.
if (!$this->table->check())
{
$this->setError($this->table->getError());

return false;
}

if (!empty($this->type))
{
$this->createTagsHelper($this->tagsObserver, $this->type, $pk, $this->typeAlias, $this->table);
}

// Store the row.
if (!$this->table->store())
{
$this->setError($this->table->getError());

return false;
}

// Run event for moved article
$dispatcher->trigger('onContentAfterSave', array('com_content.article', &$this->table, false, $fieldsData));
}

// Clean the cache
$this->cleanCache();

return true;
}

/**
* Method to test whether a record can be deleted.
*
Expand Down
Expand Up @@ -321,7 +321,7 @@ protected function getListQuery()
'c.rgt <= ' . (int) $categoryTable->rgt . ')';
}

$query->where(implode(' OR ', $subCatItemsWhere));
$query->where('(' . implode(' OR ', $subCatItemsWhere) . ')');
}

// Case: Using only the by level filter
Expand Down
Expand Up @@ -36,7 +36,7 @@
}
elseif (strpos($listOrder, 'modified') !== false)
{
$orderingColumn = 'modified';
$orderingColumn = 'modified';
}
else
{
Expand Down

0 comments on commit 77564bb

Please sign in to comment.