Release of v5.1.1-alpha5
Refactor initialization flow to accommodate future scalability and integration with all designated areas. Refactor the Creator Builders class. Refactor the FieldString and FieldXML classes.
This commit is contained in:
336 files changed
+22861
-20675
No files matched your search
@@ -17,8 +17,8 @@ use Joomla\Utilities\ArrayHelper;
|
||||
use Joomla\CMS\Router\Route;
|
||||
use Joomla\CMS\Session\Session;
|
||||
use VDM\Component\Componentbuilder\Administrator\Helper\ComponentbuilderHelper;
|
||||
use VDM\Joomla\Componentbuilder\Power\Factory as PowerFactory;
|
||||
use VDM\Joomla\Utilities\GetHelper;
|
||||
use VDM\Joomla\Componentbuilder\Power\Factory as PowerFactory;
|
||||
|
||||
// No direct access to this file
|
||||
\defined('_JEXEC') or die;
|
||||
@@ -56,14 +56,7 @@ class PowersController extends AdminController
|
||||
|
||||
|
||||
/**
|
||||
* Initializes all remote Powers and syncs them with the local database.
|
||||
*
|
||||
* This function performs several checks and operations:
|
||||
* 1. It verifies the authenticity of the request to prevent request forgery.
|
||||
* 2. It checks whether the current user has the necessary permissions to initialize the Powers.
|
||||
* 3. If the user is authorized, it attempts to initialize the remote Powers.
|
||||
* 4. Depending on the result of the initialization operation, it sets the appropriate success or error message.
|
||||
* 5. It redirects the user to a specified URL with the result message and status.
|
||||
* Redirect the request to the Initialization selection page.
|
||||
*
|
||||
* @return bool True on successful initialization, false on failure.
|
||||
*/
|
||||
@@ -73,7 +66,7 @@ class PowersController extends AdminController
|
||||
Session::checkToken() or die(Text::_('JINVALID_TOKEN'));
|
||||
|
||||
// check if user has the right
|
||||
$user = Factory::getUser();
|
||||
$user = $this->app->getIdentity();
|
||||
|
||||
// set default error message
|
||||
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_PERMISSION_DENIED') . '</h1>';
|
||||
@@ -83,29 +76,20 @@ class PowersController extends AdminController
|
||||
|
||||
if($user->authorise('power.init', 'com_componentbuilder'))
|
||||
{
|
||||
try {
|
||||
if (PowerFactory::_('Power.Remote.Get')->init())
|
||||
{
|
||||
// set success message
|
||||
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_SUCCESSFULLY_INITIALIZED_ALL_REMOTE_POWERS') . '</h1>';
|
||||
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_LOCAL_DATABASE_POWERS_HAS_SUCCESSFULLY_BEEN_SYNCED_WITH_THE_REMOTE_REPOSITORIES') . '</p>';
|
||||
// set success message
|
||||
$message = null;
|
||||
|
||||
$status = 'success';
|
||||
$success = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_INITIALIZATION_FAILED') . '</h1>';
|
||||
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_INITIALIZATION_OF_THIS_POWERS_HAS_FAILED') . '</p>';
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_INITIALIZATION_FAILED') . '</h1>';
|
||||
$message .= '<p>' . \htmlspecialchars($e->getMessage()) . '</p>';
|
||||
}
|
||||
$status = null;
|
||||
$success = true;
|
||||
|
||||
// set redirect
|
||||
$redirect_url = Route::_('index.php?option=com_componentbuilder&view=initialization_selection&power=Power&target=Powers', false);
|
||||
}
|
||||
else
|
||||
{
|
||||
// set redirect
|
||||
$redirect_url = Route::_('index.php?option=com_componentbuilder&view=powers', false);
|
||||
}
|
||||
|
||||
// set redirect
|
||||
$redirect_url = Route::_('index.php?option=com_componentbuilder&view=powers', $success);
|
||||
$this->setRedirect($redirect_url, $message, $status);
|
||||
|
||||
return $success;
|
||||
@@ -141,8 +125,8 @@ class PowersController extends AdminController
|
||||
if ($pks === [])
|
||||
{
|
||||
// set error message
|
||||
$message = '<h1>'.Text::_('COM_COMPONENTBUILDER_NO_SELECTION_DETECTED').'</h1>';
|
||||
$message .= '<p>'.Text::_('COM_COMPONENTBUILDER_PLEASE_FIRST_MAKE_A_SELECTION_FROM_THE_LIST').'</p>';
|
||||
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_NO_SELECTION_DETECTED') . '</h1>';
|
||||
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_PLEASE_FIRST_MAKE_A_SELECTION_FROM_THE_LIST') . '</p>';
|
||||
// set redirect
|
||||
$redirect_url = Route::_('index.php?option=com_componentbuilder&view=powers', false);
|
||||
$this->setRedirect($redirect_url, $message, 'error');
|
||||
@@ -153,7 +137,7 @@ class PowersController extends AdminController
|
||||
$success = false;
|
||||
|
||||
// check if user has the right
|
||||
$user = Factory::getUser();
|
||||
$user = $this->app->getIdentity();
|
||||
if($user->authorise('power.reset', 'com_componentbuilder'))
|
||||
{
|
||||
$guids = GetHelper::vars('power', $pks, 'id', 'guid');
|
||||
@@ -162,8 +146,8 @@ class PowersController extends AdminController
|
||||
if (PowerFactory::_('Power.Remote.Get')->reset($guids))
|
||||
{
|
||||
// set success message
|
||||
$message = '<h1>'.Text::_('COM_COMPONENTBUILDER_SUCCESS').'</h1>';
|
||||
$message .= '<p>'.Text::_('COM_COMPONENTBUILDER_THESE_POWERS_HAVE_SUCCESSFULLY_BEEN_RESET').'</p>';
|
||||
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_SUCCESS') . '</h1>';
|
||||
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THESE_POWERS_HAVE_SUCCESSFULLY_BEEN_RESET') . '</p>';
|
||||
$status = 'success';
|
||||
$success = true;
|
||||
}
|
||||
@@ -178,7 +162,7 @@ class PowersController extends AdminController
|
||||
}
|
||||
|
||||
// set redirect
|
||||
$redirect_url = Route::_('index.php?option=com_componentbuilder&view=powers', $success);
|
||||
$redirect_url = Route::_('index.php?option=com_componentbuilder&view=powers', false);
|
||||
$this->setRedirect($redirect_url, $message, $status);
|
||||
|
||||
return $success;
|
||||
@@ -220,8 +204,8 @@ class PowersController extends AdminController
|
||||
if ($pks === [])
|
||||
{
|
||||
// set error message
|
||||
$message = '<h1>'.Text::_('COM_COMPONENTBUILDER_NO_SELECTION_DETECTED').'</h1>';
|
||||
$message .= '<p>'.Text::_('COM_COMPONENTBUILDER_PLEASE_FIRST_MAKE_A_SELECTION_FROM_THE_LIST').'</p>';
|
||||
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_NO_SELECTION_DETECTED') . '</h1>';
|
||||
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_PLEASE_FIRST_MAKE_A_SELECTION_FROM_THE_LIST') . '</p>';
|
||||
// set redirect
|
||||
$redirect_url = Route::_('index.php?option=com_componentbuilder&view=powers', false);
|
||||
$this->setRedirect($redirect_url, $message, 'error');
|
||||
@@ -230,9 +214,10 @@ class PowersController extends AdminController
|
||||
|
||||
$status = 'error';
|
||||
$success = false;
|
||||
$message_bus = ['warning', 'error'];
|
||||
|
||||
// check if user has the right
|
||||
$user = Factory::getUser();
|
||||
$user = $this->app->getIdentity();
|
||||
if($user->authorise('power.push', 'com_componentbuilder'))
|
||||
{
|
||||
$guids = GetHelper::vars('power', $pks, 'id', 'guid');
|
||||
@@ -241,15 +226,50 @@ class PowersController extends AdminController
|
||||
if (PowerFactory::_('Power.Remote.Set')->items($guids))
|
||||
{
|
||||
// set success message
|
||||
$message = '<h1>'.Text::_('COM_COMPONENTBUILDER_SUCCESS').'</h1>';
|
||||
$message .= '<p>'.Text::_('COM_COMPONENTBUILDER_THESE_POWERS_HAVE_SUCCESSFULLY_BEEN_PUSHED').'</p>';
|
||||
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_SUCCESS') . '</h1>';
|
||||
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THESE_POWERS_HAVE_SUCCESSFULLY_BEEN_PUSHED') . '</p>';
|
||||
$status = 'success';
|
||||
$success = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Load any messages from the message bus
|
||||
$message_bucket = [];
|
||||
|
||||
foreach ($message_bus as $message_key)
|
||||
{
|
||||
if (($messages = PowerFactory::_('Power.Message')->get($message_key, null)) !== null)
|
||||
{
|
||||
$message_bucket[$message_key] = $messages;
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize base values
|
||||
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_PUSH_FAILED') . '</h1>';
|
||||
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_PUSH_OF_THESE_POWERS_HAS_FAILED') . '</p>';
|
||||
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_PUSH_OF_THIS_POWERS_HAS_FAILED') . '</p>';
|
||||
$status = 'error';
|
||||
|
||||
// Handle both error and warning
|
||||
if (isset($message_bucket['error'], $message_bucket['warning']))
|
||||
{
|
||||
$message .= '<p>' . implode('<br>', $message_bucket['error']) . '</p>';
|
||||
|
||||
foreach ($message_bucket['warning'] as $warning)
|
||||
{
|
||||
$this->app->enqueueMessage($warning, 'warning');
|
||||
}
|
||||
}
|
||||
elseif (isset($message_bucket['error']))
|
||||
{
|
||||
$message .= '<p>' . implode('<br>', $message_bucket['error']) . '</p>';
|
||||
}
|
||||
elseif (isset($message_bucket['warning']))
|
||||
{
|
||||
$status = 'warning';
|
||||
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_PUSH_WAS_UNSUCCESSFUL') . '</h1>';
|
||||
$message .= '<p>' . Text::_('COM_COMPONENTBUILDER_THE_PUSH_OF_THESE_POWERS_COULD_NOT_BE_COMPLETED') . '</p>';
|
||||
$message .= '<p>' . implode('<br>', $message_bucket['warning']) . '</p>';
|
||||
}
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$message = '<h1>' . Text::_('COM_COMPONENTBUILDER_PUSH_FAILED') . '</h1>';
|
||||
@@ -257,7 +277,7 @@ class PowersController extends AdminController
|
||||
}
|
||||
|
||||
// set redirect
|
||||
$redirect_url = Route::_('index.php?option=com_componentbuilder&view=powers', $success);
|
||||
$redirect_url = Route::_('index.php?option=com_componentbuilder&view=powers', false);
|
||||
$this->setRedirect($redirect_url, $message, $status);
|
||||
|
||||
return $success;
|
||||
|
||||
Reference in new issue
Block a user