Skip to content

Commit

Permalink
Simplify onContentPrepareForm method
Browse files Browse the repository at this point in the history
  • Loading branch information
joomdonation committed May 9, 2018
1 parent c37bf02 commit 20082cc
Showing 1 changed file with 5 additions and 16 deletions.
21 changes: 5 additions & 16 deletions plugins/system/userlogs/userlogs.php
Original file line number Diff line number Diff line change
Expand Up @@ -724,34 +724,23 @@ public function onContentPrepareForm($form, $data)
return false;
}

$lang = JFactory::getLanguage();
$lang->load('plg_system_userlogs', JPATH_ADMINISTRATOR);
$formName = $form->getName();

$allowedFormNames = array(
'com_users.profile',
'com_users.registration',
'com_users.user',
'com_admin.profile',
);

if (!in_array($formName, $allowedFormNames))
if (!in_array($formName, $allowedFormNames) || !JFactory::getUser()->authorise('core.viewlogs'))
{
return true;
}

if ($formName == 'com_admin.profile'
|| $formName == 'com_users.profile')
{
JForm::addFormPath(dirname(__FILE__) . '/forms');
$form->loadFile('userlogs', false);
$lang = JFactory::getLanguage();
$lang->load('plg_system_userlogs', JPATH_ADMINISTRATOR);

if (!JFactory::getUser()->authorise('core.viewlogs'))
{
$form->removeField('logs_notification_option');
$form->removeField('logs_notification_extensions');
}
}
JForm::addFormPath(dirname(__FILE__) . '/forms');
$form->loadFile('userlogs', false);
}

/**
Expand Down

0 comments on commit 20082cc

Please sign in to comment.