Release of v3.2.3-alpha1
Fix site view form missing classes in J4+. Fix permissions tab in items in J4+. Fix site display controller checkEditId function in J4+. Add class methods to the HtmlView classes in J4+. Fix broken toolbar call in HtmlView in J4+.
This commit is contained in:
@ -106,7 +106,7 @@ final class AllowEdit implements AllowEditInterface
|
||||
|
||||
// prepare custom permission script
|
||||
$customAllow = $this->dispenser->get(
|
||||
'php_allowedit', $nameSingleCode, '', null, true
|
||||
'php_allowedit', $nameSingleCode
|
||||
);
|
||||
|
||||
if ($this->category->exists("{$nameListCode}"))
|
||||
|
@ -0,0 +1,243 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Controller;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\Category;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\CategoryOtherName;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowEditViewsInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Controller Allow Edit Views Class for Joomla 5
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
final class AllowEditViews implements AllowEditViewsInterface
|
||||
{
|
||||
/**
|
||||
* The Permission Class.
|
||||
*
|
||||
* @var Permission
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Permission $permission;
|
||||
|
||||
/**
|
||||
* The Dispenser Class.
|
||||
*
|
||||
* @var Dispenser
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Dispenser $dispenser;
|
||||
|
||||
/**
|
||||
* The Category Class.
|
||||
*
|
||||
* @var Category
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Category $category;
|
||||
|
||||
/**
|
||||
* The CategoryOtherName Class.
|
||||
*
|
||||
* @var CategoryOtherName
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected CategoryOtherName $categoryothername;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Permission $permission The Permission Class.
|
||||
* @param Dispenser $dispenser The Dispenser Class.
|
||||
* @param Category $category The Category Class.
|
||||
* @param CategoryOtherName $categoryothername The CategoryOtherName Class.
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function __construct(Permission $permission,
|
||||
Dispenser $dispenser, Category $category,
|
||||
CategoryOtherName $categoryothername)
|
||||
{
|
||||
$this->permission = $permission;
|
||||
$this->dispenser = $dispenser;
|
||||
$this->category = $category;
|
||||
$this->categoryothername = $categoryothername;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Array Code
|
||||
*
|
||||
* @param array $views
|
||||
*
|
||||
* @since 5.0.2
|
||||
* @return string The array of Code (string)
|
||||
*/
|
||||
public function getArray(array $views): string
|
||||
{
|
||||
$allow = [];
|
||||
foreach ($views as $nameSingleCode => $nameListCode)
|
||||
{
|
||||
$allow[] = $this->getViewArray($nameSingleCode, $nameListCode);
|
||||
}
|
||||
|
||||
if ($allow === [])
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
return PHP_EOL . Indent::_(2) . implode("," . PHP_EOL . Indent::_(2), $allow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Custom Function Code
|
||||
*
|
||||
* @param array $views
|
||||
*
|
||||
* @since 5.0.2
|
||||
* @return string The functions of Code (string)
|
||||
*/
|
||||
public function getFunctions(array $views): string
|
||||
{
|
||||
$allow = [];
|
||||
foreach ($views as $nameSingleCode => $nameListCode)
|
||||
{
|
||||
if (($function = $this->getViewFunction($nameSingleCode, $nameListCode)) !== null)
|
||||
{
|
||||
$allow[] = $function;
|
||||
}
|
||||
}
|
||||
|
||||
if ($allow === [])
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
return PHP_EOL . PHP_EOL . implode(PHP_EOL . PHP_EOL, $allow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get View Permissions Array Code
|
||||
*
|
||||
* @param string $nameSingleCode The single code name of the view.
|
||||
* @param string $nameListCode The list code name of the view.
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @return string The allow edit method code
|
||||
*/
|
||||
protected function getViewArray(string $nameSingleCode, string $nameListCode): string
|
||||
{
|
||||
$allow = [];
|
||||
|
||||
// prepare custom permission script
|
||||
$customAllow = $this->dispenser->get(
|
||||
'php_allowedit', $nameSingleCode
|
||||
);
|
||||
|
||||
if ($customAllow !== '')
|
||||
{
|
||||
$allow[] = Indent::_(3) . "'function' => 'allowEdit_{$nameSingleCode}'";
|
||||
}
|
||||
|
||||
if ($this->category->exists("{$nameListCode}"))
|
||||
{
|
||||
// check if category has another name
|
||||
$otherView = $this->categoryothername->
|
||||
get($nameListCode . '.view', $nameSingleCode);
|
||||
|
||||
// check if the item has permissions.
|
||||
if ($this->permission->globalExist($otherView, 'core.access'))
|
||||
{
|
||||
$access = $this->permission->getGlobal($otherView, 'core.access');
|
||||
$allow[] = Indent::_(3) . "'access' => '{$access}'";
|
||||
}
|
||||
$edit = $this->permission->getAction($otherView, 'core.edit');
|
||||
$allow[] = Indent::_(3) . "'edit' => '{$edit}'";
|
||||
|
||||
$edit_own = $this->permission->getAction($otherView, 'core.edit.own');
|
||||
$allow[] = Indent::_(3) . "'edit.own' => '{$edit_own}'";
|
||||
}
|
||||
else
|
||||
{
|
||||
// check if the item has permissions.
|
||||
if ($this->permission->actionExist($nameSingleCode, 'core.access'))
|
||||
{
|
||||
$access = $this->permission->getAction($nameSingleCode, 'core.access');
|
||||
$allow[] = Indent::_(3) . "'access' => '{$access}'";
|
||||
}
|
||||
$edit = $this->permission->getAction($nameSingleCode, 'core.edit');
|
||||
$allow[] = Indent::_(3) . "'edit' => '{$edit}'";
|
||||
|
||||
$edit_own = $this->permission->getAction($nameSingleCode, 'core.edit.own');
|
||||
$allow[] = Indent::_(3) . "'edit.own' => '{$edit_own}'";
|
||||
}
|
||||
|
||||
return "'{$nameSingleCode}' => [" . PHP_EOL . implode(',' . PHP_EOL, $allow) . PHP_EOL . Indent::_(2) . ']';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get View Permissions Function Code
|
||||
*
|
||||
* @param string $nameSingleCode The single code name of the view.
|
||||
* @param string $nameListCode The list code name of the view.
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @return string|null The allow edit method code
|
||||
*/
|
||||
protected function getViewFunction(string $nameSingleCode, string $nameListCode): ?string
|
||||
{
|
||||
$allow = [];
|
||||
|
||||
// prepare custom permission script
|
||||
$customAllow = $this->dispenser->get(
|
||||
'php_allowedit', $nameSingleCode
|
||||
);
|
||||
|
||||
if ($customAllow !== '')
|
||||
{
|
||||
// setup the function
|
||||
$allow[] = Indent::_(1) . '/**';
|
||||
$allow[] = Indent::_(1) . " * Method to check if you can edit an existing {$nameSingleCode} record.";
|
||||
$allow[] = Indent::_(1) . ' *';
|
||||
$allow[] = Indent::_(1) . ' * @param array $data An array of input data.';
|
||||
$allow[] = Indent::_(1) . ' * @param string $key The name of the key for the primary key.';
|
||||
$allow[] = Indent::_(1) . ' *';
|
||||
$allow[] = Indent::_(1) . ' * @return boolean';
|
||||
$allow[] = Indent::_(1) . ' *';
|
||||
$allow[] = Indent::_(1) . ' * @since 5.0.2';
|
||||
$allow[] = Indent::_(1) . ' */';
|
||||
$allow[] = Indent::_(1) . "protected function allowEdit_{$nameSingleCode}(\$data = [], \$key = 'id')";
|
||||
$allow[] = Indent::_(1) . '{';
|
||||
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " get user object.";
|
||||
$allow[] = Indent::_(2) . "\$user = \$this->identity;";
|
||||
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " get record id.";
|
||||
$allow[] = Indent::_(2)
|
||||
. "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] : 0;";
|
||||
// load custom permission script
|
||||
$allow[] = $customAllow;
|
||||
$allow[] = Indent::_(1) . '}';
|
||||
|
||||
return implode(PHP_EOL, $allow);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ final class AllowEdit implements AllowEditInterface
|
||||
|
||||
// prepare custom permission script
|
||||
$customAllow = $this->dispenser->get(
|
||||
'php_allowedit', $nameSingleCode, '', null, true
|
||||
'php_allowedit', $nameSingleCode
|
||||
);
|
||||
|
||||
if ($this->category->exists("{$nameListCode}"))
|
||||
|
@ -0,0 +1,243 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Controller;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\Category;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\CategoryOtherName;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowEditViewsInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Controller Allow Edit Views Class for Joomla 4
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
final class AllowEditViews implements AllowEditViewsInterface
|
||||
{
|
||||
/**
|
||||
* The Permission Class.
|
||||
*
|
||||
* @var Permission
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Permission $permission;
|
||||
|
||||
/**
|
||||
* The Dispenser Class.
|
||||
*
|
||||
* @var Dispenser
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Dispenser $dispenser;
|
||||
|
||||
/**
|
||||
* The Category Class.
|
||||
*
|
||||
* @var Category
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Category $category;
|
||||
|
||||
/**
|
||||
* The CategoryOtherName Class.
|
||||
*
|
||||
* @var CategoryOtherName
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected CategoryOtherName $categoryothername;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Permission $permission The Permission Class.
|
||||
* @param Dispenser $dispenser The Dispenser Class.
|
||||
* @param Category $category The Category Class.
|
||||
* @param CategoryOtherName $categoryothername The CategoryOtherName Class.
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function __construct(Permission $permission,
|
||||
Dispenser $dispenser, Category $category,
|
||||
CategoryOtherName $categoryothername)
|
||||
{
|
||||
$this->permission = $permission;
|
||||
$this->dispenser = $dispenser;
|
||||
$this->category = $category;
|
||||
$this->categoryothername = $categoryothername;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Array Code
|
||||
*
|
||||
* @param array $views
|
||||
*
|
||||
* @since 5.0.2
|
||||
* @return string The array of Code (string)
|
||||
*/
|
||||
public function getArray(array $views): string
|
||||
{
|
||||
$allow = [];
|
||||
foreach ($views as $nameSingleCode => $nameListCode)
|
||||
{
|
||||
$allow[] = $this->getViewArray($nameSingleCode, $nameListCode);
|
||||
}
|
||||
|
||||
if ($allow === [])
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
return PHP_EOL . Indent::_(2) . implode("," . PHP_EOL . Indent::_(2), $allow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Custom Function Code
|
||||
*
|
||||
* @param array $views
|
||||
*
|
||||
* @since 5.0.2
|
||||
* @return string The functions of Code (string)
|
||||
*/
|
||||
public function getFunctions(array $views): string
|
||||
{
|
||||
$allow = [];
|
||||
foreach ($views as $nameSingleCode => $nameListCode)
|
||||
{
|
||||
if (($function = $this->getViewFunction($nameSingleCode, $nameListCode)) !== null)
|
||||
{
|
||||
$allow[] = $function;
|
||||
}
|
||||
}
|
||||
|
||||
if ($allow === [])
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
return PHP_EOL . PHP_EOL . implode(PHP_EOL . PHP_EOL, $allow);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get View Permissions Array Code
|
||||
*
|
||||
* @param string $nameSingleCode The single code name of the view.
|
||||
* @param string $nameListCode The list code name of the view.
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @return string The allow edit method code
|
||||
*/
|
||||
protected function getViewArray(string $nameSingleCode, string $nameListCode): string
|
||||
{
|
||||
$allow = [];
|
||||
|
||||
// prepare custom permission script
|
||||
$customAllow = $this->dispenser->get(
|
||||
'php_allowedit', $nameSingleCode
|
||||
);
|
||||
|
||||
if ($customAllow !== '')
|
||||
{
|
||||
$allow[] = Indent::_(3) . "'function' => 'allowEdit_{$nameSingleCode}'";
|
||||
}
|
||||
|
||||
if ($this->category->exists("{$nameListCode}"))
|
||||
{
|
||||
// check if category has another name
|
||||
$otherView = $this->categoryothername->
|
||||
get($nameListCode . '.view', $nameSingleCode);
|
||||
|
||||
// check if the item has permissions.
|
||||
if ($this->permission->globalExist($otherView, 'core.access'))
|
||||
{
|
||||
$access = $this->permission->getGlobal($otherView, 'core.access');
|
||||
$allow[] = Indent::_(3) . "'access' => '{$access}'";
|
||||
}
|
||||
$edit = $this->permission->getAction($otherView, 'core.edit');
|
||||
$allow[] = Indent::_(3) . "'edit' => '{$edit}'";
|
||||
|
||||
$edit_own = $this->permission->getAction($otherView, 'core.edit.own');
|
||||
$allow[] = Indent::_(3) . "'edit.own' => '{$edit_own}'";
|
||||
}
|
||||
else
|
||||
{
|
||||
// check if the item has permissions.
|
||||
if ($this->permission->actionExist($nameSingleCode, 'core.access'))
|
||||
{
|
||||
$access = $this->permission->getAction($nameSingleCode, 'core.access');
|
||||
$allow[] = Indent::_(3) . "'access' => '{$access}'";
|
||||
}
|
||||
$edit = $this->permission->getAction($nameSingleCode, 'core.edit');
|
||||
$allow[] = Indent::_(3) . "'edit' => '{$edit}'";
|
||||
|
||||
$edit_own = $this->permission->getAction($nameSingleCode, 'core.edit.own');
|
||||
$allow[] = Indent::_(3) . "'edit.own' => '{$edit_own}'";
|
||||
}
|
||||
|
||||
return "'{$nameSingleCode}' => [" . PHP_EOL . implode(',' . PHP_EOL, $allow) . PHP_EOL . Indent::_(2) . ']';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get View Permissions Function Code
|
||||
*
|
||||
* @param string $nameSingleCode The single code name of the view.
|
||||
* @param string $nameListCode The list code name of the view.
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @return string|null The allow edit method code
|
||||
*/
|
||||
protected function getViewFunction(string $nameSingleCode, string $nameListCode): ?string
|
||||
{
|
||||
$allow = [];
|
||||
|
||||
// prepare custom permission script
|
||||
$customAllow = $this->dispenser->get(
|
||||
'php_allowedit', $nameSingleCode
|
||||
);
|
||||
|
||||
if ($customAllow !== '')
|
||||
{
|
||||
// setup the function
|
||||
$allow[] = Indent::_(1) . '/**';
|
||||
$allow[] = Indent::_(1) . " * Method to check if you can edit an existing {$nameSingleCode} record.";
|
||||
$allow[] = Indent::_(1) . ' *';
|
||||
$allow[] = Indent::_(1) . ' * @param array $data An array of input data.';
|
||||
$allow[] = Indent::_(1) . ' * @param string $key The name of the key for the primary key.';
|
||||
$allow[] = Indent::_(1) . ' *';
|
||||
$allow[] = Indent::_(1) . ' * @return boolean';
|
||||
$allow[] = Indent::_(1) . ' *';
|
||||
$allow[] = Indent::_(1) . ' * @since 5.0.2';
|
||||
$allow[] = Indent::_(1) . ' */';
|
||||
$allow[] = Indent::_(1) . "protected function allowEdit_{$nameSingleCode}(\$data = [], \$key = 'id')";
|
||||
$allow[] = Indent::_(1) . '{';
|
||||
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " get user object.";
|
||||
$allow[] = Indent::_(2) . "\$user = \$this->identity;";
|
||||
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " get record id.";
|
||||
$allow[] = Indent::_(2)
|
||||
. "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] : 0;";
|
||||
// load custom permission script
|
||||
$allow[] = $customAllow;
|
||||
$allow[] = Indent::_(1) . '}';
|
||||
|
||||
return implode(PHP_EOL, $allow);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -106,7 +106,7 @@ final class AllowEdit implements AllowEditInterface
|
||||
|
||||
// prepare custom permission script
|
||||
$customAllow = $this->dispenser->get(
|
||||
'php_allowedit', $nameSingleCode, '', null, true
|
||||
'php_allowedit', $nameSingleCode
|
||||
);
|
||||
|
||||
if ($this->category->exists("{$nameListCode}"))
|
||||
|
@ -0,0 +1,218 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Controller;
|
||||
|
||||
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Creator\Permission;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Customcode\Dispenser;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\Category;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Builder\CategoryOtherName;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Indent;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Utilities\Line;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowEditViewsInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Controller Allow Edit Views Class for Joomla 3
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
final class AllowEditViews implements AllowEditViewsInterface
|
||||
{
|
||||
/**
|
||||
* The Permission Class.
|
||||
*
|
||||
* @var Permission
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Permission $permission;
|
||||
|
||||
/**
|
||||
* The Dispenser Class.
|
||||
*
|
||||
* @var Dispenser
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Dispenser $dispenser;
|
||||
|
||||
/**
|
||||
* The Category Class.
|
||||
*
|
||||
* @var Category
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected Category $category;
|
||||
|
||||
/**
|
||||
* The CategoryOtherName Class.
|
||||
*
|
||||
* @var CategoryOtherName
|
||||
* @since 5.0.2
|
||||
*/
|
||||
protected CategoryOtherName $categoryothername;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Permission $permission The Permission Class.
|
||||
* @param Dispenser $dispenser The Dispenser Class.
|
||||
* @param Category $category The Category Class.
|
||||
* @param CategoryOtherName $categoryothername The CategoryOtherName Class.
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function __construct(Permission $permission,
|
||||
Dispenser $dispenser, Category $category,
|
||||
CategoryOtherName $categoryothername)
|
||||
{
|
||||
$this->permission = $permission;
|
||||
$this->dispenser = $dispenser;
|
||||
$this->category = $category;
|
||||
$this->categoryothername = $categoryothername;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Array Code
|
||||
*
|
||||
* @param array $views
|
||||
*
|
||||
* @since 5.0.2
|
||||
* @return string The array of Code (string)
|
||||
*/
|
||||
public function getArray(array $views): string
|
||||
{
|
||||
return ''; // not used for now in Joomla 3
|
||||
}
|
||||
|
||||
/**
|
||||
* Get Custom Function Code
|
||||
*
|
||||
* @param array $views
|
||||
*
|
||||
* @since 5.0.2
|
||||
* @return string The functions of Code (string)
|
||||
*/
|
||||
public function getFunctions(array $views): string
|
||||
{
|
||||
return ''; // not used for now in Joomla 3
|
||||
}
|
||||
|
||||
/**
|
||||
* Get View Permissions Array Code
|
||||
*
|
||||
* @param string $nameSingleCode The single code name of the view.
|
||||
* @param string $nameListCode The list code name of the view.
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @return string The allow edit method code
|
||||
*/
|
||||
protected function getViewArray(string $nameSingleCode, string $nameListCode): string
|
||||
{
|
||||
$allow = [];
|
||||
|
||||
// prepare custom permission script
|
||||
$customAllow = $this->dispenser->get(
|
||||
'php_allowedit', $nameSingleCode
|
||||
);
|
||||
|
||||
if ($customAllow !== '')
|
||||
{
|
||||
$allow[] = Indent::_(3) . "'function' => 'allowEdit_{$nameSingleCode}'";
|
||||
}
|
||||
|
||||
if ($this->category->exists("{$nameListCode}"))
|
||||
{
|
||||
// check if category has another name
|
||||
$otherView = $this->categoryothername->
|
||||
get($nameListCode . '.view', $nameSingleCode);
|
||||
|
||||
// check if the item has permissions.
|
||||
if ($this->permission->globalExist($otherView, 'core.access'))
|
||||
{
|
||||
$access = $this->permission->getGlobal($otherView, 'core.access');
|
||||
$allow[] = Indent::_(3) . "'access' => '{$access}'";
|
||||
}
|
||||
$edit = $this->permission->getAction($otherView, 'core.edit');
|
||||
$allow[] = Indent::_(3) . "'edit' => '{$edit}'";
|
||||
|
||||
$edit_own = $this->permission->getAction($otherView, 'core.edit.own');
|
||||
$allow[] = Indent::_(3) . "'edit.own' => '{$edit_own}'";
|
||||
}
|
||||
else
|
||||
{
|
||||
// check if the item has permissions.
|
||||
if ($this->permission->actionExist($nameSingleCode, 'core.access'))
|
||||
{
|
||||
$access = $this->permission->getAction($nameSingleCode, 'core.access');
|
||||
$allow[] = Indent::_(3) . "'access' => '{$access}'";
|
||||
}
|
||||
$edit = $this->permission->getAction($nameSingleCode, 'core.edit');
|
||||
$allow[] = Indent::_(3) . "'edit' => '{$edit}'";
|
||||
|
||||
$edit_own = $this->permission->getAction($nameSingleCode, 'core.edit.own');
|
||||
$allow[] = Indent::_(3) . "'edit.own' => '{$edit_own}'";
|
||||
}
|
||||
|
||||
return "'{$nameSingleCode}' => [" . PHP_EOL . implode(',' . PHP_EOL, $allow) . PHP_EOL . Indent::_(2) . ']';
|
||||
}
|
||||
|
||||
/**
|
||||
* Get View Permissions Function Code
|
||||
*
|
||||
* @param string $nameSingleCode The single code name of the view.
|
||||
* @param string $nameListCode The list code name of the view.
|
||||
*
|
||||
* @since 3.2.0
|
||||
* @return string|null The allow edit method code
|
||||
*/
|
||||
protected function getViewFunction(string $nameSingleCode, string $nameListCode): ?string
|
||||
{
|
||||
$allow = [];
|
||||
|
||||
// prepare custom permission script
|
||||
$customAllow = $this->dispenser->get(
|
||||
'php_allowedit', $nameSingleCode
|
||||
);
|
||||
|
||||
if ($customAllow !== '')
|
||||
{
|
||||
// setup the function
|
||||
$allow[] = Indent::_(1) . '/**';
|
||||
$allow[] = Indent::_(1) . " * Method to check if you can edit an existing {$nameSingleCode} record.";
|
||||
$allow[] = Indent::_(1) . ' *';
|
||||
$allow[] = Indent::_(1) . ' * @param array $data An array of input data.';
|
||||
$allow[] = Indent::_(1) . ' * @param string $key The name of the key for the primary key.';
|
||||
$allow[] = Indent::_(1) . ' *';
|
||||
$allow[] = Indent::_(1) . ' * @return boolean';
|
||||
$allow[] = Indent::_(1) . ' *';
|
||||
$allow[] = Indent::_(1) . ' * @since 5.0.2';
|
||||
$allow[] = Indent::_(1) . ' */';
|
||||
$allow[] = Indent::_(1) . "protected function allowEdit_{$nameSingleCode}(\$data = [], \$key = 'id')";
|
||||
$allow[] = Indent::_(1) . '{';
|
||||
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " get user object.";
|
||||
$allow[] = Indent::_(2) . "\$user = \$this->identity;";
|
||||
$allow[] = Indent::_(2) . "//" . Line::_(__Line__, __Class__)
|
||||
. " get record id.";
|
||||
$allow[] = Indent::_(2)
|
||||
. "\$recordId = (int) isset(\$data[\$key]) ? \$data[\$key] : 0;";
|
||||
// load custom permission script
|
||||
$allow[] = $customAllow;
|
||||
$allow[] = Indent::_(1) . '}';
|
||||
|
||||
return implode(PHP_EOL, $allow);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -386,8 +386,7 @@ class Infusion extends Interpretation
|
||||
)
|
||||
&& $view['edit_create_site_view'] > 0)
|
||||
{
|
||||
$site_edit_view_array[] = Indent::_(4) . "'"
|
||||
. $nameSingleCode . "'";
|
||||
$site_edit_view_array[$nameSingleCode] = $nameListCode;
|
||||
CFactory::_('Config')->lang_target = 'both';
|
||||
// insure site view does not get removed
|
||||
CFactory::_('Config')->remove_site_edit_folder = false;
|
||||
@ -1501,9 +1500,19 @@ class Infusion extends Interpretation
|
||||
PHP_EOL . implode("," . PHP_EOL, $viewarray)
|
||||
);
|
||||
|
||||
// CUSTOM_ADMIN_EDIT_VIEW_ARRAY
|
||||
// SITE_EDIT_VIEW_ARRAY (Joomla3 only)
|
||||
CFactory::_('Compiler.Builder.Content.One')->set('SITE_EDIT_VIEW_ARRAY',
|
||||
PHP_EOL . implode("," . PHP_EOL, $site_edit_view_array)
|
||||
PHP_EOL . Indent::_(4) . "'" . implode("'," . PHP_EOL . Indent::_(4) . "'", array_keys($site_edit_view_array)) . "'"
|
||||
);
|
||||
|
||||
// SITE_ALLOW_EDIT_VIEWS_ARRAY
|
||||
CFactory::_('Compiler.Builder.Content.One')->set('SITE_ALLOW_EDIT_VIEWS_ARRAY',
|
||||
CFactory::_('Architecture.Controller.AllowEditViews')->getArray($site_edit_view_array)
|
||||
);
|
||||
|
||||
// SITE_ALLOW_EDIT_VIEWS_FUNCTIONS
|
||||
CFactory::_('Compiler.Builder.Content.One')->set('SITE_ALLOW_EDIT_VIEWS_FUNCTIONS',
|
||||
CFactory::_('Architecture.Controller.AllowEditViews')->getFunctions($site_edit_view_array)
|
||||
);
|
||||
|
||||
// MAINMENUS
|
||||
|
@ -13389,18 +13389,33 @@ class Interpretation extends Fields
|
||||
$tabs .= PHP_EOL . Indent::_(2)
|
||||
. '<div class="' . $row_class . '">';
|
||||
$tabs .= PHP_EOL . Indent::_(3) . '<div class="' . $width_class . '12">';
|
||||
$tabs .= PHP_EOL . Indent::_(4) . '<fieldset class="adminform">';
|
||||
$tabs .= PHP_EOL . Indent::_(5) . '<div class="adminformlist">';
|
||||
$tabs .= PHP_EOL . Indent::_(5)
|
||||
. "<?php foreach (\$this->form->getFieldset('accesscontrol') as \$field): ?>";
|
||||
$tabs .= PHP_EOL . Indent::_(6) . "<div>";
|
||||
$tabs .= PHP_EOL . Indent::_(7)
|
||||
. "<?php echo \$field->label; echo \$field->input;?>";
|
||||
$tabs .= PHP_EOL . Indent::_(6) . "</div>";
|
||||
$tabs .= PHP_EOL . Indent::_(6) . '<div class="clearfix"></div>';
|
||||
$tabs .= PHP_EOL . Indent::_(5) . "<?php endforeach; ?>";
|
||||
$tabs .= PHP_EOL . Indent::_(5) . "</div>";
|
||||
$tabs .= PHP_EOL . Indent::_(4) . "</fieldset>";
|
||||
if (CFactory::_('Config')->get('joomla_version', 3) == 3)
|
||||
{
|
||||
$tabs .= PHP_EOL . Indent::_(4) . '<fieldset class="adminform">';
|
||||
$tabs .= PHP_EOL . Indent::_(5) . '<div class="adminformlist">';
|
||||
$tabs .= PHP_EOL . Indent::_(5)
|
||||
. "<?php foreach (\$this->form->getFieldset('accesscontrol') as \$field): ?>";
|
||||
$tabs .= PHP_EOL . Indent::_(6) . "<div>";
|
||||
$tabs .= PHP_EOL . Indent::_(7)
|
||||
. "<?php echo \$field->label; echo \$field->input;?>";
|
||||
$tabs .= PHP_EOL . Indent::_(6) . "</div>";
|
||||
$tabs .= PHP_EOL . Indent::_(6) . '<div class="clearfix"></div>';
|
||||
$tabs .= PHP_EOL . Indent::_(5) . "<?php endforeach; ?>";
|
||||
$tabs .= PHP_EOL . Indent::_(5) . "</div>";
|
||||
$tabs .= PHP_EOL . Indent::_(4) . "</fieldset>";
|
||||
}
|
||||
else
|
||||
{
|
||||
$tabs .= PHP_EOL . Indent::_(4) . '<fieldset id="fieldset-rules" class="options-form">';
|
||||
$tabs .= PHP_EOL . Indent::_(5)
|
||||
. "<legend><?php echo Text:"
|
||||
. ":_('{$tabLangName}'); ?></legend>";
|
||||
$tabs .= PHP_EOL . Indent::_(5) . "<div>";
|
||||
$tabs .= PHP_EOL . Indent::_(6)
|
||||
. "<?php echo \$this->form->getInput('rules'); ?>";
|
||||
$tabs .= PHP_EOL . Indent::_(5) . "</div>";
|
||||
$tabs .= PHP_EOL . Indent::_(4) . "</fieldset>";
|
||||
}
|
||||
$tabs .= PHP_EOL . Indent::_(3) . "</div>";
|
||||
$tabs .= PHP_EOL . Indent::_(2) . "</div>";
|
||||
$tabs .= PHP_EOL . Indent::_(1)
|
||||
|
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/**
|
||||
* @package Joomla.Component.Builder
|
||||
*
|
||||
* @created 4th September, 2022
|
||||
* @author Llewellyn van der Merwe <https://dev.vdm.io>
|
||||
* @git Joomla Component Builder <https://git.vdm.dev/joomla/Component-Builder>
|
||||
* @copyright Copyright (C) 2015 Vast Development Method. All rights reserved.
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller;
|
||||
|
||||
|
||||
/**
|
||||
* Controller Allow Edit Views Interface
|
||||
*
|
||||
* @since 5.0.2
|
||||
*/
|
||||
interface AllowEditViewsInterface
|
||||
{
|
||||
/**
|
||||
* Get Array Code
|
||||
*
|
||||
* @param array $views
|
||||
*
|
||||
* @since 5.0.2
|
||||
* @return string The array of Code (string)
|
||||
*/
|
||||
public function getArray(array $views): string;
|
||||
|
||||
/**
|
||||
* Get Custom Function Code
|
||||
*
|
||||
* @param array $views
|
||||
*
|
||||
* @since 5.0.2
|
||||
* @return string The functions of Code (string)
|
||||
*/
|
||||
public function getFunctions(array $views): string;
|
||||
}
|
||||
|
@ -367,6 +367,7 @@ final class Header implements HeaderInterface
|
||||
$headers[] = 'use Joomla\CMS\Form\FormHelper;';
|
||||
$headers[] = 'use Joomla\CMS\Session\Session;';
|
||||
$headers[] = 'use Joomla\CMS\Uri\Uri;';
|
||||
$headers[] = 'use Joomla\CMS\User\User;';
|
||||
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
|
||||
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
|
||||
$headers[] = 'use Joomla\CMS\Layout\FileLayout;';
|
||||
@ -402,6 +403,7 @@ final class Header implements HeaderInterface
|
||||
$headers[] = 'use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;';
|
||||
$headers[] = 'use Joomla\CMS\Plugin\PluginHelper;';
|
||||
$headers[] = 'use Joomla\CMS\Toolbar\ToolbarHelper;';
|
||||
$headers[] = 'use Joomla\CMS\User\User;';
|
||||
$headers[] = 'use Joomla\CMS\Document\Document;';
|
||||
$headers[] = "use {$this->NamespacePrefix}\\Component\\{$this->ComponentNamespace}\\{$target}\\Helper\\HeaderCheck;";
|
||||
break;
|
||||
|
@ -367,6 +367,7 @@ final class Header implements HeaderInterface
|
||||
$headers[] = 'use Joomla\CMS\Form\FormHelper;';
|
||||
$headers[] = 'use Joomla\CMS\Session\Session;';
|
||||
$headers[] = 'use Joomla\CMS\Uri\Uri;';
|
||||
$headers[] = 'use Joomla\CMS\User\User;';
|
||||
$headers[] = 'use Joomla\CMS\Component\ComponentHelper;';
|
||||
$headers[] = 'use Joomla\CMS\HTML\HTMLHelper as Html;';
|
||||
$headers[] = 'use Joomla\CMS\Layout\FileLayout;';
|
||||
@ -402,6 +403,7 @@ final class Header implements HeaderInterface
|
||||
$headers[] = 'use Joomla\CMS\MVC\View\HtmlView as BaseHtmlView;';
|
||||
$headers[] = 'use Joomla\CMS\Plugin\PluginHelper;';
|
||||
$headers[] = 'use Joomla\CMS\Toolbar\ToolbarHelper;';
|
||||
$headers[] = 'use Joomla\CMS\User\User;';
|
||||
$headers[] = 'use Joomla\CMS\Document\Document;';
|
||||
$headers[] = "use {$this->NamespacePrefix}\\Component\\{$this->ComponentNamespace}\\{$target}\\Helper\\HeaderCheck;";
|
||||
break;
|
||||
|
@ -22,6 +22,10 @@ use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\Allo
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Controller\AllowEdit as J5ControllerAllowEdit;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Controller\AllowEdit as J4ControllerAllowEdit;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Controller\AllowEdit as J3ControllerAllowEdit;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Interfaces\Architecture\Controller\AllowEditViewsInterface;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFive\Controller\AllowEditViews as J5ControllerAllowEditViews;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaFour\Controller\AllowEditViews as J4ControllerAllowEditViews;
|
||||
use VDM\Joomla\Componentbuilder\Compiler\Architecture\JoomlaThree\Controller\AllowEditViews as J3ControllerAllowEditViews;
|
||||
|
||||
|
||||
/**
|
||||
@ -72,6 +76,18 @@ class ArchitectureController implements ServiceProviderInterface
|
||||
|
||||
$container->alias(J3ControllerAllowEdit::class, 'Architecture.Controller.J3.AllowEdit')
|
||||
->share('Architecture.Controller.J3.AllowEdit', [$this, 'getJ3ControllerAllowEdit'], true);
|
||||
|
||||
$container->alias(AllowEditViewsInterface::class, 'Architecture.Controller.AllowEditViews')
|
||||
->share('Architecture.Controller.AllowEditViews', [$this, 'getAllowEditViews'], true);
|
||||
|
||||
$container->alias(J5ControllerAllowEditViews::class, 'Architecture.Controller.J5.AllowEditViews')
|
||||
->share('Architecture.Controller.J5.AllowEditViews', [$this, 'getJ5ControllerAllowEditViews'], true);
|
||||
|
||||
$container->alias(J4ControllerAllowEditViews::class, 'Architecture.Controller.J4.AllowEditViews')
|
||||
->share('Architecture.Controller.J4.AllowEditViews', [$this, 'getJ4ControllerAllowEditViews'], true);
|
||||
|
||||
$container->alias(J3ControllerAllowEditViews::class, 'Architecture.Controller.J3.AllowEditViews')
|
||||
->share('Architecture.Controller.J3.AllowEditViews', [$this, 'getJ3ControllerAllowEditViews'], true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -216,6 +232,78 @@ class ArchitectureController implements ServiceProviderInterface
|
||||
$container->get('Compiler.Builder.Category'),
|
||||
$container->get('Compiler.Builder.Category.Other.Name')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The AllowEditViewsInterface Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return AllowEditViewsInterface
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function getAllowEditViews(Container $container): AllowEditViewsInterface
|
||||
{
|
||||
if (empty($this->targetVersion))
|
||||
{
|
||||
$this->targetVersion = $container->get('Config')->joomla_version;
|
||||
}
|
||||
|
||||
return $container->get('Architecture.Controller.J' . $this->targetVersion . '.AllowEditViews');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The AllowEditViews Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J5ControllerAllowEdit
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function getJ5ControllerAllowEditViews(Container $container): J5ControllerAllowEditViews
|
||||
{
|
||||
return new J5ControllerAllowEditViews(
|
||||
$container->get('Compiler.Creator.Permission'),
|
||||
$container->get('Customcode.Dispenser'),
|
||||
$container->get('Compiler.Builder.Category'),
|
||||
$container->get('Compiler.Builder.Category.Other.Name')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The AllowEditViews Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J4ControllerAllowEditViews
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function getJ4ControllerAllowEditViews(Container $container): J4ControllerAllowEditViews
|
||||
{
|
||||
return new J4ControllerAllowEditViews(
|
||||
$container->get('Compiler.Creator.Permission'),
|
||||
$container->get('Customcode.Dispenser'),
|
||||
$container->get('Compiler.Builder.Category'),
|
||||
$container->get('Compiler.Builder.Category.Other.Name')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get The AllowEditViews Class.
|
||||
*
|
||||
* @param Container $container The DI container.
|
||||
*
|
||||
* @return J3ControllerAllowEditViews
|
||||
* @since 5.0.2
|
||||
*/
|
||||
public function getJ3ControllerAllowEditViews(Container $container): J3ControllerAllowEditViews
|
||||
{
|
||||
return new J3ControllerAllowEditViews(
|
||||
$container->get('Compiler.Creator.Permission'),
|
||||
$container->get('Customcode.Dispenser'),
|
||||
$container->get('Compiler.Builder.Category'),
|
||||
$container->get('Compiler.Builder.Category.Other.Name')
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user