<?php

	class XenStaff_Addtab
	{

		public static function navigationTabs(array &$extraTabs, $selectedTabId)
		{

			$options = XenForo_Application::get('options');

			if ($options->displaystaffActive)
			{


		                $staffGroupsModel = new XenStaff_Model_StaffGroups();
		                $staffGroupsUserIdsModel = new XenStaff_Model_StaffGroupsUserIds();
		                $staffGroupsUniqueIdsModel = new XenStaff_Model_StaffGroupsUniqueIds();

		                $staffGroups = $staffGroupsModel->getSelectedUserGroups();
		                $staffGroupsUserIds = $staffGroupsUserIdsModel->getListofUsersPerStaffGroup();
		                $staffIds = $staffGroupsUniqueIdsModel->getListofUniqueIds($staffGroupsUserIds);

		                $visitor = XenForo_Visitor::getInstance();


		                if (($options->displaystafftoAll) OR (in_array($visitor['user_id'], $staffIds)))
		                {

				       if (!$options->stafftabName)
				       {
					       $options->stafftabName = 'Staff';
				       }

				       $extraTabs['xfx_staff'] = array(
				       'title' => $options->stafftabName,
				       'selected' => ($selectedTabId == 'xfx_staff'),
				       'href' => XenForo_Link::buildPublicLink('XenStaff'),
				       'linksTemplate' => 'XenStaff_links',
				       'linksTitle' => $staffGroups
				       );

		                }

			}


		}


	}
