• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

XF 1.1 Making admin logs available to those with the permission and not super admins

lasertits

Active member
#1
To cut straight to the point, I'm curious if I can change the way admin logs are handled to where users with the 'view logs' permission can view it.

Currently only super administrators can view it but I want to give some of my forum admins the ability to see it without making them super admins.



Now even if someone has the 'view logs' permission the admin log page will still hit you with:
You must be a super administrator to access this page. This can be configured in the file library/config.php.
Is it at all possible to make it so admins can see the admin logs without having to be super admins? Where is this restriction even defined if I wanted to make a code edit / hack? I'd rather not have to edit any code of course but if that's what I have to do I'll consider it.

If anyone has any ideas or insight I'd appreciate it greatly. Thanks!
 

Jake Bunce

XenForo moderator
Staff member
#2
library/XenForo/ControllerAdmin/Log.php

Add the red code to comment out the super admin requirement:

Code:
	public function actionAdmin()
	{
		// $this->assertSuperAdmin();

		$logModel = $this->_getLogModel();

		$id = $this->_input->filterSingle('id', XenForo_Input::UINT);
		if ($id)
		{
			$entry = $logModel->getAdminLogById($id);
			if (!$entry)
			{
				return $this->responseError(new XenForo_Phrase('requested_log_entry_not_found'), 404);
			}

			$entry['requestData'] = json_decode($entry['request_data'], true);

			$viewParams = array(
				'entry' => $logModel->prepareAdminLogEntry($entry)
			);
			return $this->responseView('XenForo_ViewAdmin_Log_AdminView', 'log_admin_view', $viewParams);
		}
		else
		{
			$userId = $this->_input->filterSingle('user_id', XenForo_Input::UINT);
			$page = $this->_input->filterSingle('page', XenForo_Input::UINT);
			$perPage = 20;

			$pageParams = array();
			if ($userId)
			{
				$pageParams['user_id'] = $userId;
			}

			$entries = $logModel->getAdminLogEntries($userId, array('page' => $page, 'perPage' => $perPage));

			$viewParams = array(
				'entries' => $logModel->prepareAdminLogEntries($entries),
				'total' => $logModel->countAdminLogEntries($userId),
				'page' => $page,
				'perPage' => $perPage,
				'pageParams' => $pageParams,

				'logUsers' => $logModel->getUsersWithAdminLogs(),
				'userId' => $userId
			);

			return $this->responseView('XenForo_ViewAdmin_Log_Admin', 'log_admin', $viewParams);
		}
	}
This can be done with an addon instead of a file edit if you are so inclined.
 

lasertits

Active member
#3
This can be done with an addon instead of a file edit if you are so inclined.
I really wish I were, sadly my addon knowledge doesn't go beyond very simple listeners and controllers. I need to find a tutorial on altering already existing functions or something, perhaps one already exists. I shall go look!

Glad to know this is a possibility at least and can be done. You're helpful as always Jake, thanks!