Replace Factory::getUser() with Factory::getApplication()->getIdentity()

This commit is contained in:
Tuan Pham Ngoc 2021-07-17 11:49:07 +07:00
parent 92d01d2bc6
commit 01bc443bc0
7 changed files with 11 additions and 11 deletions

View File

@ -71,7 +71,7 @@ class WeblinkModel extends AdminModel
return false;
}
return Factory::getUser()->authorise('core.delete', 'com_weblinks.category.' . (int) $record->catid);
return Factory::getApplication()->getIdentity()->authorise('core.delete', 'com_weblinks.category.' . (int) $record->catid);
}
/**
@ -87,7 +87,7 @@ class WeblinkModel extends AdminModel
{
if (!empty($record->catid))
{
return Factory::getUser()->authorise('core.edit.state', 'com_weblinks.category.' . (int) $record->catid);
return Factory::getApplication()->getIdentity()->authorise('core.edit.state', 'com_weblinks.category.' . (int) $record->catid);
}
return parent::canEditState($record);
@ -239,7 +239,7 @@ class WeblinkModel extends AdminModel
protected function prepareTable($table)
{
$date = Factory::getDate();
$user = Factory::getUser();
$user = Factory::getApplication()->getIdentity();
$table->title = htmlspecialchars_decode($table->title, ENT_QUOTES);
$table->alias = ApplicationHelper::stringURLSafe($table->alias);
@ -434,6 +434,6 @@ class WeblinkModel extends AdminModel
*/
private function canCreateCategory()
{
return Factory::getUser()->authorise('core.create', 'com_weblinks');
return Factory::getApplication()->getIdentity()->authorise('core.create', 'com_weblinks');
}
}

View File

@ -156,7 +156,7 @@ class WeblinksModel extends ListModel
// Create a new query object.
$db = $this->getDbo();
$query = $db->getQuery(true);
$user = Factory::getUser();
$user = Factory::getApplication()->getIdentity();
// Select the required fields from the table.
$query->select(

View File

@ -111,7 +111,7 @@ class CategoryModel extends ListModel
*/
protected function getListQuery()
{
$viewLevels = Factory::getUser()->getAuthorisedViewLevels();
$viewLevels = Factory::getApplication()->getIdentity()->getAuthorisedViewLevels();
// Create a new query object.
$db = $this->getDbo();
@ -263,7 +263,7 @@ class CategoryModel extends ListModel
$id = $app->input->get('id', 0, 'int');
$this->setState('category.id', $id);
$user = Factory::getUser();
$user = Factory::getApplication()->getIdentity();
if (!$user->authorise('core.edit.state', 'com_weblinks') && !$user->authorise('core.edit', 'com_weblinks'))
{

View File

@ -97,7 +97,7 @@ class FormModel extends WeblinkModel
$form = $this->loadForm('com_weblinks.form', 'weblink', array('control' => 'jform', 'load_data' => $loadData));
// Disable the buttons and just allow editor none for not authenticated users
if (Factory::getUser()->guest)
if (Factory::getApplication()->getIdentity()->guest)
{
$form->setFieldAttribute('description', 'editor', 'none');
$form->setFieldAttribute('description', 'buttons', 'no');

View File

@ -74,7 +74,7 @@ class WeblinkModel extends ItemModel
*/
public function getItem($pk = null)
{
$user = Factory::getUser();
$user = Factory::getApplication()->getIdentity();
$pk = (!empty($pk)) ? $pk : (int) $this->getState('weblink.id');

View File

@ -68,7 +68,7 @@ class HtmlView extends BaseHtmlView
*/
public function display($tpl = null)
{
$user = Factory::getUser();
$user = Factory::getApplication()->getIdentity();
// Get model data.
$this->state = $this->get('State');

View File

@ -21,7 +21,7 @@ use Joomla\CMS\Uri\Uri;
$params = &$this->category->params;
// Get the user object.
$user = Factory::getUser();
$user = Factory::getApplication()->getIdentity();
// Check if user is allowed to add/edit based on weblinks permissinos.
$canEdit = $user->authorise('core.edit', 'com_weblinks.category.' . $this->category->id);