Skip to content

Commit

Permalink
Merge branch 'hotfix/1.1.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
qzminski committed Apr 21, 2020
2 parents b7e8a62 + 70f3607 commit b4e036f
Show file tree
Hide file tree
Showing 8 changed files with 170 additions and 7 deletions.
27 changes: 20 additions & 7 deletions src/EventListener/ContentListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

use Contao\CoreBundle\Exception\AccessDeniedException;
use Contao\DataContainer;
use Contao\Input;
use Contao\StringUtil;
use Doctrine\DBAL\Connection;
use Terminal42\NodeBundle\Model\NodeModel;
Expand Down Expand Up @@ -44,16 +45,21 @@ public function __construct(Connection $db, PermissionChecker $permissionChecker
/**
* On data container load callback.
*/
public function onLoadCallback(): void
public function onLoadCallback(DataContainer $dc): void
{
$node = $this->db->fetchColumn('SELECT type FROM tl_node WHERE id=?', [CURRENT_ID]);
// Determine the node type
if ($dc->table === 'tl_content' && Input::get('act')) {
$type = $this->db->fetchColumn('SELECT type FROM tl_node WHERE id=(SELECT pid FROM tl_content WHERE id=? AND ptable=?)', [$dc->id, 'tl_node']);
} else {
$type = $this->db->fetchColumn('SELECT type FROM tl_node WHERE id=?', [$dc->id]);
}

// Throw an exception if the node is not present or is of a folder type
if (!$node || NodeModel::TYPE_FOLDER === $node) {
if (!$type || NodeModel::TYPE_FOLDER === $type) {
throw new AccessDeniedException('Node of folder type cannot have content elements');
}

$this->checkPermissions();
$this->checkPermissions($dc);
}

/**
Expand Down Expand Up @@ -92,14 +98,21 @@ public function onNodesSaveCallback(?string $value, DataContainer $dc): string
/**
* Check the permissions.
*/
private function checkPermissions(): void
private function checkPermissions(DataContainer $dc): void
{
if (!$this->permissionChecker->hasUserPermission(PermissionChecker::PERMISSION_CONTENT)) {
throw new AccessDeniedException('The user is not allowed to manage the node content');
}

if (!$this->permissionChecker->isUserAllowedNode(CURRENT_ID)) {
throw new AccessDeniedException(sprintf('The user is not allowed to manage the content of node ID %s', CURRENT_ID));
// Determine the node ID
if ($dc->table === 'tl_content' && Input::get('act')) {
$nodeId = $this->db->fetchColumn('SELECT pid FROM tl_content WHERE id=? AND ptable=?', [$dc->id, 'tl_node']);
} else {
$nodeId = $dc->id;
}

if (!$this->permissionChecker->isUserAllowedNode($nodeId)) {
throw new AccessDeniedException(sprintf('The user is not allowed to manage the content of node ID %s', $nodeId));
}
}
}
19 changes: 19 additions & 0 deletions src/Resources/contao/languages/cs/default.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

/*
* Node Bundle for Contao Open Source CMS.
*
* @copyright Copyright (c) 2019, terminal42 gmbh
* @author terminal42 <https://terminal42.ch>
* @license MIT
*/

/*
* Content elements
*/
$GLOBALS['TL_LANG']['CTE']['nodes'] = ['Nodes', 'Začlenit jeden nebo více elementů.'];

/*
* Errors
*/
$GLOBALS['TL_LANG']['ERR']['invalidNodes'] = 'Elemnty typu "složka" nejsou povolené: %s';
19 changes: 19 additions & 0 deletions src/Resources/contao/languages/cs/modules.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

/*
* Node Bundle for Contao Open Source CMS.
*
* @copyright Copyright (c) 2019, terminal42 gmbh
* @author terminal42 <https://terminal42.ch>
* @license MIT
*/

/*
* Backend modules
*/
$GLOBALS['TL_LANG']['MOD']['nodes'] = ['Nodes', 'Vytvořit a spravovat nodes s elementy.'];

/*
* Frontend modules
*/
$GLOBALS['TL_LANG']['FMD']['nodes'] = &$GLOBALS['TL_LANG']['CTE']['nodes'];
11 changes: 11 additions & 0 deletions src/Resources/contao/languages/cs/tl_cfg_tag.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?php

/*
* Node Bundle for Contao Open Source CMS.
*
* @copyright Copyright (c) 2019, terminal42 gmbh
* @author terminal42 <https://terminal42.ch>
* @license MIT
*/

$GLOBALS['TL_LANG']['tl_cfg_tag']['sourceRef']['terminal42_node'] = 'Node';
13 changes: 13 additions & 0 deletions src/Resources/contao/languages/cs/tl_content.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

/*
* Node Bundle for Contao Open Source CMS.
*
* @copyright Copyright (c) 2019, terminal42 gmbh
* @author terminal42 <https://terminal42.ch>
* @license MIT
*/

$GLOBALS['TL_LANG']['tl_content']['nodes'] = ['Nodes', 'Vyberte jeden nebo více prvků.'];
$GLOBALS['TL_LANG']['tl_content']['nodesWrapper'] = ['Přidat wrapper', 'Tím bude přidán div kolem vybraného elementu.'];

44 changes: 44 additions & 0 deletions src/Resources/contao/languages/cs/tl_node.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?php

/*
* Node Bundle for Contao Open Source CMS.
*
* @copyright Copyright (c) 2019, terminal42 gmbh
* @author terminal42 <https://terminal42.ch>
* @license MIT
*/

$GLOBALS['TL_LANG']['tl_node']['name'] = ['Název', 'Zadejte prosím vlastní název tohoto prvku.'];
$GLOBALS['TL_LANG']['tl_node']['type'] = ['Typ', 'Zde můžete vybrat jeden z dostupných typů.'];
$GLOBALS['TL_LANG']['tl_node']['languages'] = ['Jazyky', 'Zde můžete nastavit jazyky, které lze použít pro filtraci prvků v backendu.'];
$GLOBALS['TL_LANG']['tl_node']['tags'] = ['Štítky', 'Sem můžete zadat štítky, které lze použít pro filtraci prvků v backendu.'];
$GLOBALS['TL_LANG']['tl_node']['pid'] = ['Rodičkovský node'];
$GLOBALS['TL_LANG']['tl_node']['tstamp'] = ['Datum změny'];

/*
* Legends
*/
$GLOBALS['TL_LANG']['tl_node']['name_legend'] = 'Název a typ';
$GLOBALS['TL_LANG']['tl_node']['filter_legend'] = 'Nastavení filtru';

/*
* Reference
*/
$GLOBALS['TL_LANG']['tl_node']['typeRef'] = [
\Terminal42\NodeBundle\Model\NodeModel::TYPE_CONTENT => 'Obsah',
\Terminal42\NodeBundle\Model\NodeModel::TYPE_FOLDER => 'Složka',
];

/*
* Buttons
*/
$GLOBALS['TL_LANG']['tl_node']['new'] = ['Nový prvek', 'Vytvořit nový prvek'];
$GLOBALS['TL_LANG']['tl_node']['show'] = ['Podrobnosti', 'Zobrazit podrobnosti k ID %s'];
$GLOBALS['TL_LANG']['tl_node']['edit'] = ['Upravit prvek', 'Upravit ID %s'];
$GLOBALS['TL_LANG']['tl_node']['editheader'] = ['Upravit nastavení prvku', 'Změnit nastavení prvku'];
$GLOBALS['TL_LANG']['tl_node']['cut'] = ['Přesunout prvek', 'Přesunout prvek ID %s'];
$GLOBALS['TL_LANG']['tl_node']['copy'] = ['Duplikovat prvek', 'Duplikovat ID %s'];
$GLOBALS['TL_LANG']['tl_node']['copyChilds'] = ['Duplikovat prvek i s jeho podprvky', 'Duplikovat prvek i s jeho podprvky ID %s'];
$GLOBALS['TL_LANG']['tl_node']['delete'] = ['Smazat prvek', 'Smazat prvek ID %s'];
$GLOBALS['TL_LANG']['tl_node']['pasteafter'] = ['Včlenit do', 'Včlenit prvek ID %s'];
$GLOBALS['TL_LANG']['tl_node']['pasteinto'] = ['Umístit za', 'Umístit ID %s za'];
28 changes: 28 additions & 0 deletions src/Resources/contao/languages/cs/tl_user.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

/*
* Node Bundle for Contao Open Source CMS.
*
* @copyright Copyright (c) 2019, terminal42 gmbh
* @author terminal42 <https://terminal42.ch>
* @license MIT
*/

$GLOBALS['TL_LANG']['tl_user']['nodeMounts'] = ['Nastavení přístupu', 'Zde můžete nastavit přístup k jednomu nebo více prvkům (Podprvky budou automaticky přidány).'];
$GLOBALS['TL_LANG']['tl_user']['nodePermissions'] = ['Přístupová práva', 'Zde můžete nastavit přístupová práva.'];

/*
* Reference
*/
$GLOBALS['TL_LANG']['tl_user']['nodePermissionsRef'] = [
\Terminal42\NodeBundle\PermissionChecker::PERMISSION_CREATE => 'Vytvořit prvky',
\Terminal42\NodeBundle\PermissionChecker::PERMISSION_EDIT => 'Upravit prvky',
\Terminal42\NodeBundle\PermissionChecker::PERMISSION_DELETE => 'Smazat prvky',
\Terminal42\NodeBundle\PermissionChecker::PERMISSION_CONTENT => 'Spravovat prvky',
\Terminal42\NodeBundle\PermissionChecker::PERMISSION_ROOT => 'Spravovat klíčové prvky',
];

/*
* Legends
*/
$GLOBALS['TL_LANG']['tl_user']['node_legend'] = 'Nastavení';
16 changes: 16 additions & 0 deletions src/Resources/contao/languages/cs/tl_user_group.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

/*
* Node Bundle for Contao Open Source CMS.
*
* @copyright Copyright (c) 2019, terminal42 gmbh
* @author terminal42 <https://terminal42.ch>
* @license MIT
*/

\Contao\System::loadLanguageFile('tl_user_group');

/*
* Legends
*/
$GLOBALS['TL_LANG']['tl_user_group']['node_legend'] = &$GLOBALS['TL_LANG']['tl_user']['node_legend'];

0 comments on commit b4e036f

Please sign in to comment.