Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.0] Namespace com_privacy #24586

Merged
merged 39 commits into from
Apr 14, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
13378fd
Declare namespace
mbabker Apr 13, 2019
9782f52
Namespace controllers
mbabker Apr 13, 2019
cd1c8e3
Namespace the export data objects, add class alias mapping
mbabker Apr 13, 2019
9e16f4b
Namespace removal status data object
mbabker Apr 13, 2019
0c72288
Move forms
mbabker Apr 13, 2019
53d99a7
Namespace form fields
mbabker Apr 13, 2019
536033f
Namespace plugin class
mbabker Apr 13, 2019
ab94577
Namespace tables
mbabker Apr 13, 2019
0f11de2
Namespace models
mbabker Apr 13, 2019
6adbb80
Namespace HTML helper
mbabker Apr 13, 2019
585426c
Namespace PrivacyHelper
mbabker Apr 13, 2019
a3b3b3c
Namespace display controller
mbabker Apr 13, 2019
b2f0802
Add privacy component extension class
mbabker Apr 13, 2019
1565490
Add service provider
mbabker Apr 13, 2019
47a6aca
Add component dispatcher and remove entry point file
mbabker Apr 13, 2019
1dce7a0
Move the templates
mbabker Apr 13, 2019
6d6ec01
Namespace view classes
mbabker Apr 13, 2019
4149054
Fix JText -> Text
mbabker Apr 13, 2019
a0d7b07
Fix HTML helper uses
mbabker Apr 13, 2019
93c45ed
Fix PrivacyHelper loading
mbabker Apr 13, 2019
f2a87bc
Add table to alias map and remove loading
mbabker Apr 13, 2019
3f4c413
Remove loading for PrivacyPlugin since it is aliased
mbabker Apr 13, 2019
1d08673
Fix namespace references
mbabker Apr 13, 2019
c2d249a
Call static getInstance to get model since com_actionlogs isn't names…
mbabker Apr 13, 2019
2623741
Fix JRoute -> Route
mbabker Apr 13, 2019
de18958
Namespace frontend controllers
mbabker Apr 13, 2019
42f6d98
Namespace the component router
mbabker Apr 13, 2019
778779f
Move forms
mbabker Apr 13, 2019
39a3c90
Fix namespaces
mbabker Apr 13, 2019
848cf7b
Namespace models
mbabker Apr 13, 2019
d1aa36d
Fix JFactory -> Factory
mbabker Apr 13, 2019
04c69a5
Move templates
mbabker Apr 13, 2019
77ba9fb
Remove front controller
mbabker Apr 13, 2019
f1c09c7
Namespace views
mbabker Apr 13, 2019
2be4b7a
Fix HTML helper use in module
mbabker Apr 13, 2019
6530115
Fix notifySuperUsers method
mbabker Apr 13, 2019
4270d90
Fix DateInterval reference
mbabker Apr 13, 2019
45f6f64
Fix PHPCS
mbabker Apr 14, 2019
1009caf
Fix doc blocks
mbabker Apr 14, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
25 changes: 14 additions & 11 deletions administrator/components/com_messages/Model/MessageModel.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,17 @@

defined('_JEXEC') or die;

use Joomla\CMS\Access\Access;
use Joomla\CMS\Access\Rule;
use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Language;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Log\Log;
use Joomla\CMS\MVC\Model\AdminModel;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\Table\Asset;
use Joomla\CMS\Table\Table;
use Joomla\CMS\User\User;

/**
Expand Down Expand Up @@ -446,17 +449,17 @@ public function notifySuperUsers($subject, $message, $fromUser = null)

try
{
/** @var JTableAsset $table */
$table = $this->getTable('Asset', 'JTable');
/** @var Asset $table */
$table = Table::getInstance('Asset');
$rootId = $table->getRootId();

/** @var JAccessRule[] $rules */
$rules = JAccess::getAssetRules($rootId)->getData();
/** @var Rule[] $rules */
$rules = Access::getAssetRules($rootId)->getData();
$rawGroups = $rules['core.admin']->getData();

if (empty($rawGroups))
{
$this->setError(JText::_('COM_MESSAGES_ERROR_MISSING_ROOT_ASSET_GROUPS'));
$this->setError(Text::_('COM_MESSAGES_ERROR_MISSING_ROOT_ASSET_GROUPS'));

return false;
}
Expand All @@ -473,7 +476,7 @@ public function notifySuperUsers($subject, $message, $fromUser = null)

if (empty($groups))
{
$this->setError(JText::_('COM_MESSAGES_ERROR_NO_GROUPS_SET_AS_SUPER_USER'));
$this->setError(Text::_('COM_MESSAGES_ERROR_NO_GROUPS_SET_AS_SUPER_USER'));

return false;
}
Expand All @@ -487,7 +490,7 @@ public function notifySuperUsers($subject, $message, $fromUser = null)

if (empty($userIDs))
{
$this->setError(JText::_('COM_MESSAGES_ERROR_NO_USERS_SET_AS_SUPER_USER'));
$this->setError(Text::_('COM_MESSAGES_ERROR_NO_USERS_SET_AS_SUPER_USER'));

return false;
}
Expand All @@ -498,12 +501,12 @@ public function notifySuperUsers($subject, $message, $fromUser = null)
* All messages must have a valid from user, we have use cases where an unauthenticated user may trigger this
* so we will set the from user as the to user
*/
$data = array(
$data = [
'user_id_from' => $id,
'user_id_to' => $id,
'subject' => $subject,
'message' => $message,
);
];

if (!$this->save($data))
{
Expand All @@ -513,7 +516,7 @@ public function notifySuperUsers($subject, $message, $fromUser = null)

return true;
}
catch (Exception $exception)
catch (\Exception $exception)
{
$this->setError($exception->getMessage());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,21 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\Component\Privacy\Administrator\Controller;

defined('_JEXEC') or die;

use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\FormController;
use Joomla\CMS\Router\Route;
use Joomla\Component\Privacy\Administrator\Model\ConsentsModel;

/**
* Consents management controller class.
*
* @since 3.9.0
*/
class PrivacyControllerConsents extends JControllerForm
class ConsentsController extends FormController
{
/**
* Method to invalidate specific consents.
Expand All @@ -26,18 +33,18 @@ class PrivacyControllerConsents extends JControllerForm
public function invalidate($key = null, $urlVar = null)
{
// Check for request forgeries
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
$this->checkToken();

$ids = $this->input->get('cid', array(), 'array');
$ids = $this->input->get('cid', [], 'array');

if (empty($ids))
{
$this->setError(JText::_('JERROR_NO_ITEMS_SELECTED'));
$this->setError(Text::_('JERROR_NO_ITEMS_SELECTED'));
}
else
{
// Get the model.
/** @var PrivacyModelConsents $model */
/** @var ConsentsModel $model */
$model = $this->getModel();

// Publish the items.
Expand All @@ -46,10 +53,10 @@ public function invalidate($key = null, $urlVar = null)
$this->setError($model->getError());
}

$message = JText::plural('COM_PRIVACY_N_CONSENTS_INVALIDATED', count($ids));
$message = Text::plural('COM_PRIVACY_N_CONSENTS_INVALIDATED', count($ids));
}

$this->setRedirect(JRoute::_('index.php?option=com_privacy&view=consents', false), $message);
$this->setRedirect(Route::_('index.php?option=com_privacy&view=consents', false), $message);
}

/**
Expand All @@ -62,21 +69,21 @@ public function invalidate($key = null, $urlVar = null)
public function invalidateAll()
{
// Check for request forgeries
JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
$this->checkToken();

$filters = $this->input->get('filter', array(), 'array');
$filters = $this->input->get('filter', [], 'array');

if (isset($filters['subject']) && $filters['subject'] != '')
{
$subject = $filters['subject'];
}
else
{
$this->setError(JText::_('JERROR_NO_ITEMS_SELECTED'));
$this->setError(Text::_('JERROR_NO_ITEMS_SELECTED'));
}

// Get the model.
/** @var PrivacyModelConsents $model */
/** @var ConsentsModel $model */
$model = $this->getModel();

// Publish the items.
Expand All @@ -85,8 +92,8 @@ public function invalidateAll()
$this->setError($model->getError());
}

$message = JText::_('COM_PRIVACY_CONSENTS_INVALIDATED_ALL');
$message = Text::_('COM_PRIVACY_CONSENTS_INVALIDATED_ALL');

$this->setRedirect(JRoute::_('index.php?option=com_privacy&view=consents', false), $message);
$this->setRedirect(Route::_('index.php?option=com_privacy&view=consents', false), $message);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,26 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\Component\Privacy\Administrator\Controller;

defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\MVC\Controller\BaseController;
use Joomla\CMS\MVC\Model\BaseDatabaseModel;
use Joomla\CMS\Response\JsonResponse;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Session\Session;
use Joomla\Component\Privacy\Administrator\Helper\PrivacyHelper;
use Joomla\Component\Privacy\Administrator\Model\RequestsModel;

/**
* Privacy Controller
*
* @since 3.9.0
*/
class PrivacyController extends JControllerLegacy
class DisplayController extends BaseController
{
/**
* The default view.
Expand All @@ -39,12 +46,10 @@ class PrivacyController extends JControllerLegacy
*
* @since 3.9.0
*/
public function display($cachable = false, $urlparams = array())
public function display($cachable = false, $urlparams = [])
{
JLoader::register('PrivacyHelper', JPATH_ADMINISTRATOR . '/components/com_privacy/helpers/privacy.php');

// Get the document object.
$document = JFactory::getDocument();
$document = Factory::getDocument();

// Set the default view name and format from the Request.
$vName = $this->input->get('view', $this->default_view);
Expand All @@ -70,10 +75,10 @@ public function display($cachable = false, $urlparams = array())
// For the default layout, we need to also push the action logs model into the view
if ($lName === 'default')
{
JLoader::register('ActionlogsHelper', JPATH_ADMINISTRATOR . '/components/com_actionlogs/helpers/actionlogs.php');
JModelLegacy::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_actionlogs/models', 'ActionlogsModel');
\JLoader::register('ActionlogsHelper', JPATH_ADMINISTRATOR . '/components/com_actionlogs/helpers/actionlogs.php');
BaseDatabaseModel::addIncludePath(JPATH_ADMINISTRATOR . '/components/com_actionlogs/models', 'ActionlogsModel');

$logsModel = $this->getModel('Actionlogs', 'ActionlogsModel');
$logsModel = BaseDatabaseModel::getInstance('Actionlogs', 'ActionlogsModel');

// Set default ordering for the context
$logsModel->setState('list.fullordering', 'a.log_date DESC');
Expand All @@ -83,11 +88,11 @@ public function display($cachable = false, $urlparams = array())
}

// For the edit layout, if mail sending is disabled then redirect back to the list view as the form is unusable in this state
if ($lName === 'edit' && !JFactory::getConfig()->get('mailonline', 1))
if ($lName === 'edit' && !Factory::getConfig()->get('mailonline', 1))
{
$this->setRedirect(
JRoute::_('index.php?option=com_privacy&view=requests', false),
JText::_('COM_PRIVACY_WARNING_CANNOT_CREATE_REQUEST_WHEN_SENDMAIL_DISABLED'),
Route::_('index.php?option=com_privacy&view=requests', false),
Text::_('COM_PRIVACY_WARNING_CANNOT_CREATE_REQUEST_WHEN_SENDMAIL_DISABLED'),
'warning'
);

Expand All @@ -112,9 +117,9 @@ public function display($cachable = false, $urlparams = array())
/**
* Fetch and report number urgent privacy requests in JSON format, for AJAX requests
*
* @return void
* @return void
*
* @since 3.9.0
* @since 3.9.0
*/
public function getNumberUrgentRequests()
{
Expand All @@ -129,12 +134,10 @@ public function getNumberUrgentRequests()
$app->close();
}

/** @var PrivacyModelRequests $model */
/** @var RequestsModel $model */
$model = $this->getModel('requests');
$numberUrgentRequests = $model->getNumberUrgentRequests();

echo new JResponseJson(array('number_urgent_requests' => $numberUrgentRequests));

$app->close();
echo new JsonResponse(['number_urgent_requests' => $numberUrgentRequests]);
}
}