Skip to content

Commit

Permalink
Replace Factory::getUser() with $this->getCurrentUser() (#38006)
Browse files Browse the repository at this point in the history
  • Loading branch information
joomdonation authored Jun 9, 2022
1 parent f8b855e commit bb2e172
Show file tree
Hide file tree
Showing 50 changed files with 61 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class HtmlView extends BaseHtmlView
public function display($tpl = null): void
{
// Access check.
if (!Factory::getUser()->authorise('core.admin'))
if (!$this->getCurrentUser()->authorise('core.admin'))
{
throw new NotAllowed(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ public function display($tpl = null)
*/
protected function addToolbar()
{
$user = Factory::getUser();
$user = $this->getCurrentUser();

if (isset($this->typeName) && isset($this->extensionName))
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ protected function addToolbar(): void
{
Factory::getApplication()->input->set('hidemainmenu', true);

$user = Factory::getUser();
$user = $this->getCurrentUser();
$userId = $user->id;
$isNew = ($this->item->id == 0);
$checkedOut = !(\is_null($this->item->checked_out) || $this->item->checked_out == $userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ protected function addToolbar(): void
{
Factory::getApplication()->input->set('hidemainmenu', true);

$user = Factory::getUser();
$user = $this->getCurrentUser();
$isNew = ($this->item->id == 0);
$checkedOut = !(\is_null($this->item->checked_out) || $this->item->checked_out == $user->id);
$canDo = $this->canDo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ protected function addToolbar(): void
ToolbarHelper::divider();
}

if (Factory::getUser()->authorise('core.admin', 'com_cache'))
if ($this->getCurrentUser()->authorise('core.admin', 'com_cache'))
{
ToolbarHelper::preferences('com_cache');
ToolbarHelper::divider();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public function display($tpl = null)
protected function addToolbar()
{
$extension = Factory::getApplication()->input->get('extension');
$user = Factory::getUser();
$user = $this->getCurrentUser();
$userId = $user->id;

$isNew = ($this->item->id == 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public function display($tpl = null)
// Load Form and Data
$form = $this->get('form');
$data = $this->get('data');
$user = Factory::getUser();
$user = $this->getCurrentUser();
}
catch (\Exception $e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public function display($tpl = null)
}

$form = $this->get('form');
$user = Factory::getUser();
$user = $this->getCurrentUser();
}
catch (\Exception $e)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected function addToolbar()
{
Factory::getApplication()->input->set('hidemainmenu', true);

$user = Factory::getUser();
$user = $this->getCurrentUser();
$userId = $user->id;
$isNew = ($this->item->id == 0);
$checkedOut = !(is_null($this->item->checked_out) || $this->item->checked_out == $userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ public function display($tpl = null)
protected function addToolbar()
{
Factory::getApplication()->input->set('hidemainmenu', true);
$user = Factory::getUser();
$user = $this->getCurrentUser();
$userId = $user->id;
$isNew = ($this->item->id == 0);
$checkedOut = !(is_null($this->item->checked_out) || $this->item->checked_out == $userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ protected function addToolbar()
{
$component = $this->state->get('field.component');
$section = $this->state->get('field.section');
$userId = Factory::getUser()->get('id');
$userId = $this->getCurrentUser()->get('id');
$canDo = $this->canDo;

$isNew = ($this->item->id == 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ protected function addToolbar()
$toolbar->addNew('field.add');
}

if ($canDo->get('core.edit.state') || Factory::getUser()->authorise('core.admin'))
if ($canDo->get('core.edit.state') || $this->getCurrentUser()->authorise('core.admin'))
{
$dropdown = $toolbar->dropdownButton('status-group')
->text('JTOOLBAR_CHANGE_STATUS')
Expand All @@ -172,7 +172,7 @@ protected function addToolbar()
$childBar->archive('fields.archive')->listCheck(true);
}

if (Factory::getUser()->authorise('core.admin'))
if ($this->getCurrentUser()->authorise('core.admin'))
{
$childBar->checkin('fields.checkin')->listCheck(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected function addToolbar()
$component = $parts[0];
}

$userId = Factory::getUser()->get('id');
$userId = $this->getCurrentUser()->get('id');
$canDo = $this->canDo;

$isNew = ($this->item->id == 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ protected function addToolbar()
$toolbar->addNew('group.add');
}

if ($canDo->get('core.edit.state') || Factory::getUser()->authorise('core.admin'))
if ($canDo->get('core.edit.state') || $this->getCurrentUser()->authorise('core.admin'))
{
$dropdown = $toolbar->dropdownButton('status-group')
->text('JTOOLBAR_CHANGE_STATUS')
Expand All @@ -174,7 +174,7 @@ protected function addToolbar()
$childBar->archive('groups.archive')->listCheck(true);
}

if (Factory::getUser()->authorise('core.admin'))
if ($this->getCurrentUser()->authorise('core.admin'))
{
$childBar->checkin('groups.checkin')->listCheck(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected function addToolbar()
Factory::getApplication()->input->set('hidemainmenu', true);

$isNew = ($this->item->filter_id == 0);
$checkedOut = !(is_null($this->item->checked_out) || $this->item->checked_out == Factory::getUser()->id);
$checkedOut = !(is_null($this->item->checked_out) || $this->item->checked_out == $this->getCurrentUser()->id);
$canDo = ContentHelper::getActions('com_finder');

// Configure the toolbar.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class HtmlView extends InstallerViewDefault
*/
public function display($tpl = null)
{
if (!Factory::getUser()->authorise('core.admin'))
if (!$this->getCurrentUser()->authorise('core.admin'))
{
throw new NotAllowed(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class HtmlView extends InstallerViewDefault
*/
public function display($tpl = null)
{
if (!Factory::getUser()->authorise('core.admin'))
if (!$this->getCurrentUser()->authorise('core.admin'))
{
throw new NotAllowed(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ protected function addToolbar()
}

// Add toolbar buttons.
if (Factory::getUser()->authorise('core.admin'))
if ($this->getCurrentUser()->authorise('core.admin'))
{
ToolbarHelper::preferences('com_joomlaupdate');
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ protected function addToolbar()
ToolbarHelper::deleteList('JGLOBAL_CONFIRM_DELETE', 'overrides.delete', 'JTOOLBAR_DELETE');
}

if (Factory::getUser()->authorise('core.admin'))
if ($this->getCurrentUser()->authorise('core.admin'))
{
ToolbarHelper::custom('overrides.purge', 'refresh', '', 'COM_LANGUAGES_VIEW_OVERRIDES_PURGE', false);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ protected function addToolbar()
{
// Get the toolbar object instance
$toolbar = Toolbar::getInstance('toolbar');
$user = Factory::getUser();
$user = $this->getCurrentUser();

ToolbarHelper::title(Text::_('COM_MAILS_MAILS_TITLE'), 'envelope');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ protected function prepareToolbar()

// Get the toolbar object instance
$bar = Toolbar::getInstance('toolbar');
$user = Factory::getUser();
$user = $this->getCurrentUser();

// Set the title
ToolbarHelper::title(Text::_('COM_MEDIA'), 'images mediamanager');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ protected function addToolbar()
$input = Factory::getApplication()->input;
$input->set('hidemainmenu', true);

$user = Factory::getUser();
$user = $this->getCurrentUser();
$isNew = ($this->item->id == 0);
$checkedOut = !(is_null($this->item->checked_out) || $this->item->checked_out == $user->get('id'));
$canDo = $this->canDo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ protected function addToolbar()
$menutypeId = (int) $this->state->get('menutypeid');

$canDo = ContentHelper::getActions('com_menus', 'menu', (int) $menutypeId);
$user = Factory::getUser();
$user = $this->getCurrentUser();

// Get the menu title
$menuTypeTitle = $this->get('State')->get('menutypetitle');
Expand All @@ -344,7 +344,7 @@ protected function addToolbar()

$protected = $this->state->get('filter.menutype') == 'main';

if (($canDo->get('core.edit.state') || Factory::getUser()->authorise('core.admin')) && !$protected
if (($canDo->get('core.edit.state') || $this->getCurrentUser()->authorise('core.admin')) && !$protected
|| $canDo->get('core.edit.state') && $this->state->get('filter.client_id') == 0)
{
$dropdown = $toolbar->dropdownButton('status-group')
Expand All @@ -363,7 +363,7 @@ protected function addToolbar()
$childBar->unpublish('items.unpublish')->listCheck(true);
}

if (Factory::getUser()->authorise('core.admin') && !$protected)
if ($this->getCurrentUser()->authorise('core.admin') && !$protected)
{
$childBar->checkin('items.checkin')->listCheck(true);
}
Expand Down Expand Up @@ -393,7 +393,7 @@ protected function addToolbar()
}
}

if (Factory::getUser()->authorise('core.admin'))
if ($this->getCurrentUser()->authorise('core.admin'))
{
$toolbar->standardButton('refresh')
->text('JTOOLBAR_REBUILD')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ protected function addToolbar()
{
Factory::getApplication()->input->set('hidemainmenu', true);

$user = Factory::getUser();
$user = $this->getCurrentUser();
$isNew = ($this->item->id == 0);
$checkedOut = !(is_null($this->item->checked_out) || $this->item->checked_out == $user->get('id'));
$canDo = $this->canDo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ protected function addToolbar()
{
$state = $this->get('State');
$canDo = ContentHelper::getActions('com_modules');
$user = Factory::getUser();
$user = $this->getCurrentUser();

// Get the toolbar object instance
$toolbar = Toolbar::getInstance('toolbar');
Expand All @@ -200,7 +200,7 @@ protected function addToolbar()
->onclick("location.href='index.php?option=com_modules&view=select&client_id=" . $this->state->get('client_id', 0) . "'");
}

if (!$this->isEmptyState && ($canDo->get('core.edit.state') || Factory::getUser()->authorise('core.admin')))
if (!$this->isEmptyState && ($canDo->get('core.edit.state') || $this->getCurrentUser()->authorise('core.admin')))
{
$dropdown = $toolbar->dropdownButton('status-group')
->text('JTOOLBAR_CHANGE_STATUS')
Expand All @@ -218,7 +218,7 @@ protected function addToolbar()
$childBar->unpublish('modules.unpublish')->listCheck(true);
}

if (Factory::getUser()->authorise('core.admin'))
if ($this->getCurrentUser()->authorise('core.admin'))
{
$childBar->checkin('modules.checkin')->listCheck(true);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ protected function addToolbar()
{
Factory::getApplication()->input->set('hidemainmenu', true);

$user = Factory::getUser();
$user = $this->getCurrentUser();
$isNew = ($this->item->id == 0);
$checkedOut = !(is_null($this->item->checked_out) || $this->item->checked_out == $user->get('id'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private function toolbar()
}

// Options button.
if (Factory::getUser()->authorise('core.admin', 'com_postinstall'))
if ($this->getCurrentUser()->authorise('core.admin', 'com_postinstall'))
{
$toolbar->preferences('com_postinstall');
$toolbar->help('Post-installation_Messages_for_Joomla_CMS');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ protected function addToolbar()
{
Factory::getApplication()->input->set('hidemainmenu', true);

$user = Factory::getUser();
$user = $this->getCurrentUser();
$userId = $user->get('id');
$isNew = ($this->item->id == 0);
$checkedOut = !(is_null($this->item->checked_out) || $this->item->checked_out == $userId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ public function display($tpl = null)

$this->addToolbar();

if (!Factory::getUser()->authorise('core.admin'))
if (!$this->getCurrentUser()->authorise('core.admin'))
{
$this->setLayout('readonly');
}
Expand All @@ -242,7 +242,7 @@ public function display($tpl = null)
protected function addToolbar()
{
$app = Factory::getApplication();
$user = Factory::getUser();
$user = $this->getCurrentUser();
$app->input->set('hidemainmenu', true);

// User is global SuperUser
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class HtmlView extends BaseHtmlView
public function display($tpl = null)
{
// Access check.
if (!Factory::getUser()->authorise('core.manage', 'com_users'))
if (!$this->getCurrentUser()->authorise('core.manage', 'com_users'))
{
throw new NotAllowed(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class HtmlView extends BaseHtmlView
public function display($tpl = null)
{
// Access check.
if (!Factory::getUser()->authorise('core.manage', 'com_users'))
if (!$this->getCurrentUser()->authorise('core.manage', 'com_users'))
{
throw new NotAllowed(Text::_('JERROR_ALERTNOAUTHOR'), 403);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ protected function addToolbar()
$input = Factory::getApplication()->input;
$input->set('hidemainmenu', 1);

$user = Factory::getUser();
$user = $this->getCurrentUser();
$isNew = ($this->item->id == 0);
$checkedOut = !(is_null($this->item->checked_out) || $this->item->checked_out == $user->get('id'));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public function display($tpl = null)
protected function addToolbar()
{
$canDo = $this->canDo;
$user = Factory::getUser();
$user = $this->getCurrentUser();

// Get the toolbar object instance
$toolbar = Toolbar::getInstance('toolbar');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ protected function addToolbar()
{
Factory::getApplication()->input->set('hidemainmenu', true);

$user = Factory::getUser();
$user = $this->getCurrentUser();
$userId = $user->id;
$isNew = empty($this->item->id);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ protected function addToolbar()
{
$canDo = ContentHelper::getActions($this->extension, 'workflow', $this->workflowID);

$user = Factory::getUser();
$user = $this->getCurrentUser();

$toolbar = Toolbar::getInstance('toolbar');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ protected function addToolbar()
{
Factory::getApplication()->input->set('hidemainmenu', true);

$user = Factory::getUser();
$user = $this->getCurrentUser();
$userId = $user->id;
$isNew = empty($this->item->id);

Expand Down
Loading

0 comments on commit bb2e172

Please sign in to comment.