Skip to content

Commit

Permalink
Merge branch '5.x' into remove-raw-block + fix merge error
Browse files Browse the repository at this point in the history
# Conflicts:
#	plugins/GrapesJsBuilderBundle/Assets/library/js/dist/builder.js
  • Loading branch information
LordRembo committed Apr 26, 2024
2 parents bc17f9a + 3e95053 commit 4c0b6af
Show file tree
Hide file tree
Showing 105 changed files with 11,248 additions and 1,970 deletions.
18 changes: 18 additions & 0 deletions app/bundles/ApiBundle/ApiEvents.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,22 @@ final class ApiEvents
* @var string
*/
public const API_ON_ENTITY_POST_SAVE = 'mautic.api_on_entity_post_save';

/**
* The mautic.api_pre_serialization_context event is dispatched before the serialization context is created for the view.
*
* The event listener receives a Mautic\ApiBundle\Event\ApiSerializationContextEvent instance.
*
* @var string
*/
public const API_PRE_SERIALIZATION_CONTEXT = 'mautic.api_pre_serialization_context';

/**
* The mautic.api_post_serialization_context event is dispatched after the serialization context is created for the view.
*
* The event listener receives a Mautic\ApiBundle\Event\ApiSerializationContextEvent instance.
*
* @var string
*/
public const API_POST_SERIALIZATION_CONTEXT = 'mautic.api_post_serialization_context';
}
15 changes: 15 additions & 0 deletions app/bundles/ApiBundle/Controller/FetchCommonApiController.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
use FOS\RestBundle\Controller\AbstractFOSRestController;
use FOS\RestBundle\View\View;
use JMS\Serializer\Exclusion\ExclusionStrategyInterface;
use Mautic\ApiBundle\ApiEvents;
use Mautic\ApiBundle\Event\ApiSerializationContextEvent;
use Mautic\ApiBundle\Helper\BatchIdToEntityHelper;
use Mautic\ApiBundle\Helper\EntityResultHelper;
use Mautic\ApiBundle\Serializer\Exclusion\ParentChildrenExclusionStrategy;
Expand Down Expand Up @@ -679,6 +681,13 @@ protected function setBatchError(int $key, string $msg, int $code, array &$error
protected function setSerializationContext(View $view): void
{
$context = $view->getContext();

if ($this->dispatcher->hasListeners(ApiEvents::API_PRE_SERIALIZATION_CONTEXT)) {
$apiSerializationContextEvent = new ApiSerializationContextEvent($context, $this->getCurrentRequest());
$this->dispatcher->dispatch($apiSerializationContextEvent, ApiEvents::API_PRE_SERIALIZATION_CONTEXT);
$context = $apiSerializationContextEvent->getContext();
}

if (!empty($this->serializerGroups)) {
$context->setGroups($this->serializerGroups);
}
Expand All @@ -705,6 +714,12 @@ protected function setSerializationContext(View $view): void
$context->setSerializeNull(true);
}

if ($this->dispatcher->hasListeners(ApiEvents::API_POST_SERIALIZATION_CONTEXT)) {
$apiSerializationContextEvent = new ApiSerializationContextEvent($context, $this->getCurrentRequest());
$this->dispatcher->dispatch($apiSerializationContextEvent, ApiEvents::API_POST_SERIALIZATION_CONTEXT);
$context = $apiSerializationContextEvent->getContext();
}

$view->setContext($context);
}

Expand Down
31 changes: 31 additions & 0 deletions app/bundles/ApiBundle/Event/ApiSerializationContextEvent.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace Mautic\ApiBundle\Event;

use FOS\RestBundle\Context\Context;
use Mautic\CoreBundle\Event\CommonEvent;
use Symfony\Component\HttpFoundation\Request;

final class ApiSerializationContextEvent extends CommonEvent
{
public function __construct(private Context $context, private Request $request)
{
}

public function getContext(): Context
{
return $this->context;
}

public function setContext(Context $context): void
{
$this->context = $context;
}

public function getRequest(): Request
{
return $this->request;
}
}
2 changes: 1 addition & 1 deletion app/bundles/AssetBundle/Entity/Asset.php
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ class Asset extends FormEntity
/**
* @var bool|null
*/
private $disallow = false;
private $disallow = true;

public static function loadMetadata(ORM\ClassMetadata $metadata): void
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
{% block listResults %}
{% if items|length %}
<div class="table-responsive">
<table class="table table-hover table-striped table-bordered asset-list" id="assetTable">
<table class="table table-hover asset-list" id="assetTable">
<thead>
<tr>
{{- include(
Expand Down
1 change: 1 addition & 0 deletions app/bundles/CampaignBundle/Assets/css/campaign.css
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
width: 206px;
padding: 10px 15px;
border-radius: 6px;
margin-bottom: 10px;
}

.campaign-builder .builder-active {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

{% if items|length > 0 %}
<div class="table-responsive">
<table class="table table-hover table-striped table-bordered campaign-list" id="campaignTable">
<table class="table table-hover campaign-list" id="campaignTable">
<thead>
<tr>
{{- include('@MauticCore/Helper/tableheader.html.twig', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
{% block listResults %}
{% if items|length %}
<div class="table-responsive">
<table class="table table-hover table-striped table-bordered category-list" id="categoryTable">
<table class="table table-hover category-list" id="categoryTable">
<thead>
<tr>
{{- include('@MauticCore/Helper/tableheader.html.twig', {
Expand Down
13 changes: 9 additions & 4 deletions app/bundles/CoreBundle/Assets/css/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -2589,6 +2589,9 @@ ul.line-legend li {
.table-responsive-force > .table-bordered > tfoot > tr:last-child > td {
border-bottom: 0;
}
.table-hover > tbody > tr:hover {
transition: var(--all);
}
.progress {
background-color: #ebedf0;
-webkit-box-shadow: none;
Expand Down Expand Up @@ -4773,10 +4776,14 @@ body.noscroll {
.table .input-group-sm > .input-group-addon {
font-size: 10px;
line-height: 1em;
background-color: transparent;
border: 0;
padding: 0;
}
.table .input-group-sm .dropdown-toggle {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border: 0;
background-color: transparent;
padding: 5px 8px;
}
.input-group .input-group-btn button {
height: 32px;
Expand Down Expand Up @@ -4891,7 +4898,6 @@ ul.media-list.media-list-feed div.media-object {
.ui-sortable-handle:active {
cursor: grabbing;
}

.flex-column-inline {
display: inline-flex;
flex-direction: column;
Expand All @@ -4906,7 +4912,6 @@ ul.media-list.media-list-feed div.media-object {
width: 100px;
margin: 50px;
}

.flip-vertically {
transform: scaleY(-1);
}
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,9 @@

}
}

.table-hover {
> tbody > tr:hover {
transition: var(--all);
}
}
8 changes: 6 additions & 2 deletions app/bundles/CoreBundle/Assets/css/app/less/custom.less
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,15 @@ body.noscroll {
& > .input-group-addon {
font-size: 10px;
line-height: 1em;
background-color: transparent;
border: 0;
padding: 0;
}

.dropdown-toggle {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border: 0;
background-color: transparent;
padding: 5px 8px;
}
}

Expand Down
13 changes: 13 additions & 0 deletions app/bundles/CoreBundle/Assets/js/11.editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,19 @@ Mautic.GetCkEditorConfigOptions = function(ckEditorToolbarOptions, tokenCallbac
fontSize: {
options: [8, 9, 10, 11, 12, 14, 18, 24, 30, 36, 48, 72],
supportAllValues : true
},
link: {
decorators: {
// based on: https://ckeditor.com/docs/ckeditor5/latest/features/link.html#adding-target-and-rel-attributes-to-external-links
openInNewTab: {
mode: 'manual',
label: 'Open in a new tab',
attributes: {
target: '_blank',
rel: 'noopener noreferrer'
}
}
}
}
};

Expand Down
51 changes: 0 additions & 51 deletions app/bundles/CoreBundle/Form/Type/DynamicContentTrait.php

This file was deleted.

5 changes: 5 additions & 0 deletions app/bundles/CoreBundle/IpLookup/AbstractLocalDataLookup.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,11 @@ public function downloadRemoteDataStore()
{
$package = $this->getRemoteDateStoreDownloadUrl();

if (empty($package)) {
$this->logger->error('Failed to fetch remote IP data: Invalid or inactive MaxMind license key');

return false;
}
try {
$data = $this->client->get($package, [
RequestOptions::ALLOW_REDIRECTS => true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ id="{{ id|escape }}" name="{{ full_name|escape }}" {{ disabled ? 'disabled="disa
<label {% for k, v in label_attr %}
{{ '%s="%s" '|format(k|escape, v|escape)|raw }}
{% endfor %}{{ tooltip ? 'data-toggle="tooltip" data-container="body" data-placement="top" title="%s"'|format(tooltip)|raw : ''}}>
{{ label|trans({}, translation_domain)|escape }}{{ tooltip ? ' <i class="fa fa-question-circle"></i>' : '' }}</label>
{{ label_html ? label|trans({}, translation_domain)|purify : label|trans({}, translation_domain)|escape }}{{ tooltip ? ' <i class="fa fa-question-circle"></i>' : '' }}</label>
{% endif %}
{% endblock form_label %}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
<div class="col-xs-4 col-sm-2 pl-0 pr-0 pt-10 pb-10 text-right">
<i class="hidden-xs fa {{ typeOneIconClass }} fa-lg"></i>
<button class="visible-xs pull-right btn btn-sm btn-default btn-nospin text-primary" onclick="{{ typeOneOnClick }}">
{{ 'mautic.core.select' }}
{{ 'mautic.core.select'|trans }}
</button>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
),
'data-toggle': editMode
}),
iconClass: 'ri-edit-circle-line',
iconClass: 'ri-edit-line',
btnText: 'mautic.core.form.edit'|trans,
primary: true
}) }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@

{% set firstItem = items|first %}
<div class="table-responsive">
<table class="table table-hover table-striped table-bordered {{ sessionVar }}-list">
<table class="table table-hover {{ sessionVar }}-list">
<thead>
<tr>
{% if ignoreStandardColumns is empty %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

{% if items|length %}
<div class="table-responsive">
<table class="table table-hover table-striped table-bordered theme-list" id="themeTable">
<table class="table table-hover theme-list" id="themeTable">
<thead>
<tr>
{{ include('@MauticCore/Helper/tableheader.html.twig', {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ public function isGranted($userPermissions, $name, $level)
if (!isset($userPermissions[$name])) {
// the user doesn't have implicit access
return false;
} elseif ($this->permissions[$name]['full'] & $userPermissions[$name]) {
} elseif (isset($this->permissions[$name]['full']) && $this->permissions[$name]['full'] & $userPermissions[$name]) {
return true;
} else {
// otherwise test for specific level
Expand Down Expand Up @@ -272,7 +272,7 @@ public function getPermissionRatio(array $data)
if (in_array('full', $perms)) {
if (1 === count($perms)) {
// full is the only permission so count as 1
if (!empty($data[$level]) && in_array('full', $data[$level])) {
if (!empty($data[$level]) && !in_array('full', $data[$level])) {
++$totalGranted;
}
} else {
Expand Down Expand Up @@ -302,6 +302,31 @@ public function parseForJavascript(array &$perms): void
{
}

/**
* @param array<int|string> $permissions
*/
protected function addCustomPermission(string $level, array $permissions): void
{
$this->permissions[$level] = $permissions;
}

/**
* Adds a custom permission to the form builder, i.e. config only bundles.
*
* @param array<string> $choices
* @param array<string> $data
*/
protected function addCustomFormFields(string $bundle, string $level, FormBuilderInterface &$builder, string $label, array $choices, array $data): void
{
$builder->add("$bundle:$level", PermissionListType::class, [
'choices' => $choices,
'label' => $label,
'data' => (!empty($data[$level]) ? $data[$level] : []),
'bundle' => $bundle,
'level' => $level,
]);
}

/**
* Adds the standard permission set of view, edit, create, delete, publish and full.
*
Expand Down

0 comments on commit 4c0b6af

Please sign in to comment.