<?php

	class XenStaff_Model_StaffGroups extends XenForo_Model
	{	

	// returns selected group id's and title

		public function getSelectedUserGroups()
		{

			$userGroups = array();

			foreach ($this->getAllSelectedUserGroups() AS $userGroup)
			{

  				$userGroups[] = array(
				'title' => $userGroup['title'],
				'group_id' => $userGroup['user_group_id']
				);

                        }

			return $userGroups;

		}

		public function getAllSelectedUserGroups()
		{

                        $staffgroups = XenForo_Application::get('options')->staffdisplayGroups;

                        if (empty($staffgroups))
                        {
                                $staffgroups = array(3,4);
                        }

                        $staffgroups = implode(',', $staffgroups);

			return $this->_getDb()->fetchAll('
			SELECT user_group_id, title
			FROM xf_user_group
			WHERE user_group_id IN (' . $staffgroups . ')
			ORDER BY user_group_id
			');

		}

	}