public static function getAuthorisedViewLevels($userId)
	{
		// Get all groups that the user is mapped to recursively.
		$groups = self::getGroupsByUser($userId);

		// Only load the view levels once.
		if (empty(self::$viewLevels))
		{
			// Build the view levels array.
			$levels = Viewlevel::all()
				->rows();

			foreach ($levels as $level)
			{
				self::$viewLevels[$level->get('id')] = (array) json_decode($level->get('rules'));
			}
		}

		// Initialise the authorised array.
		$authorised = array(1);

		// Find the authorised levels.
		foreach (self::$viewLevels as $level => $rule)
		{
			foreach ($rule as $id)
			{
				if (($id < 0) && (($id * -1) == $userId))
				{
					$authorised[] = $level;
					break;
				}
				// Check to see if the group is mapped to the level.
				elseif (($id >= 0) && in_array($id, $groups))
				{
					$authorised[] = $level;
					break;
				}
			}
		}

		return $authorised;
	}
public static function getAuthorisedViewLevels($userId)
	{
		// Get all groups that the user is mapped to recursively.
		$groups = self::getGroupsByUser($userId);

		// Only load the view levels once.
		if (empty(self::$viewLevels))
		{
			// Build the view levels array.
			$levels = Viewlevel::all()
				->rows();

			foreach ($levels as $level)
			{
				self::$viewLevels[$level->get('id')] = (array) json_decode($level->get('rules'));
			}
		}

		// Initialise the authorised array.
		$authorised = array(1);

		// Find the authorised levels.
		foreach (self::$viewLevels as $level => $rule)
		{
			foreach ($rule as $id)
			{
				if (($id < 0) && (($id * -1) == $userId))
				{
					$authorised[] = $level;
					break;
				}
				// Check to see if the group is mapped to the level.
				elseif (($id >= 0) && in_array($id, $groups))
				{
					$authorised[] = $level;
					break;
				}
			}
		}

		return $authorised;
	}
public static function getAuthorisedViewLevels ( $ userId ) { // Get all groups that the user is mapped to recursively. $ groups = self :: getGroupsByUser ( $ userId ) ; // Only load the view levels once. if ( empty ( self :: $ viewLevels ) ) { // Build the view levels array. $ levels = Viewlevel :: all ( ) -> rows ( ) ; foreach ( $ levels as $ level ) { self :: $ viewLevels [ $ level -> get ( 'id' ) ] = ( array ) json_decode ( $ level -> get ( 'rules' ) ) ; } } // Initialise the authorised array. $ authorised = array ( 1 ) ; // Find the authorised levels. foreach ( self :: $ viewLevels as $ level => $ rule ) { foreach ( $ rule as $ id ) { if ( ( $ id < 0 ) && ( ( $ id * - 1 ) == $ userId ) ) { $ authorised [ ] = $ level ; break ; } // Check to see if the group is mapped to the level. elseif ( ( $ id >= 0 ) && in_array ( $ id , $ groups ) ) { $ authorised [ ] = $ level ; break ; } } } return $ authorised ; }
Method to return a list of view levels for which the user is authorised.

@param   integer  $userId  Id of the user for which to get the list of authorised view levels.
@return  array    List of view levels for which the user is authorised.
Method to return a list of view levels for which the user is authorised .