public static function getGroupsMatchingTagString($usertags, $usergroups)
	{
		//database object
		$database = \App::get('db');

		//turn users tag string into array
		$mytags = ($usertags != '') ? array_map('trim', explode(',', $usertags)) : array();

		//users groups
		$mygroups = array();
		if (is_array($usergroups))
		{
			foreach ($usergroups as $ug)
			{
				$mygroups[] = $ug->gidNumber;
			}
		}

		//query the databse for all published, type "HUB" groups
		$sql = "SELECT g.gidNumber, g.cn, g.description, g.public_desc
				FROM `#__xgroups` AS g
				WHERE g.type=1
				AND g.published=1
				AND g.discoverability=0";
		$database->setQuery($sql);

		//get all groups
		$groups = $database->loadObjectList();

		//loop through each group and see if there is a tag match
		foreach ($groups as $k => $group)
		{
			//get the groups tags
			$gt = new \Components\Groups\Models\Tags($group->gidNumber);

			$group->tags = $gt->render('string');
			$group->tags = array_map('trim', explode(',', $group->tags));

			//get common tags
			$group->matches = array_intersect($mytags, $group->tags);

			//remove tags from the group object since its no longer needed
			unset($group->tags);

			//if we dont have a match remove group from return results
			//or if we are already a member of the group remove from return results
			if (count($group->matches) < 1 || in_array($group->gidNumber, $mygroups))
			{
				unset($groups[$k]);
			}
		}

		return $groups;
	}
public static function getGroupsMatchingTagString($usertags, $usergroups)
	{
		//database object
		$database = \App::get('db');

		//turn users tag string into array
		$mytags = ($usertags != '') ? array_map('trim', explode(',', $usertags)) : array();

		//users groups
		$mygroups = array();
		if (is_array($usergroups))
		{
			foreach ($usergroups as $ug)
			{
				$mygroups[] = $ug->gidNumber;
			}
		}

		//query the databse for all published, type "HUB" groups
		$sql = "SELECT g.gidNumber, g.cn, g.description, g.public_desc
				FROM `#__xgroups` AS g
				WHERE g.type=1
				AND g.published=1
				AND g.discoverability=0";
		$database->setQuery($sql);

		//get all groups
		$groups = $database->loadObjectList();

		//loop through each group and see if there is a tag match
		foreach ($groups as $k => $group)
		{
			//get the groups tags
			$gt = new \Components\Groups\Models\Tags($group->gidNumber);

			$group->tags = $gt->render('string');
			$group->tags = array_map('trim', explode(',', $group->tags));

			//get common tags
			$group->matches = array_intersect($mytags, $group->tags);

			//remove tags from the group object since its no longer needed
			unset($group->tags);

			//if we dont have a match remove group from return results
			//or if we are already a member of the group remove from return results
			if (count($group->matches) < 1 || in_array($group->gidNumber, $mygroups))
			{
				unset($groups[$k]);
			}
		}

		return $groups;
	}
public static function getGroupsMatchingTagString ( $ usertags , $ usergroups ) { //database object $ database = \ App :: get ( 'db' ) ; //turn users tag string into array $ mytags = ( $ usertags != '' ) ? array_map ( 'trim' , explode ( ',' , $ usertags ) ) : array ( ) ; //users groups $ mygroups = array ( ) ; if ( is_array ( $ usergroups ) ) { foreach ( $ usergroups as $ ug ) { $ mygroups [ ] = $ ug -> gidNumber ; } } //query the databse for all published, type "HUB" groups $ sql = "SELECT g.gidNumber, g.cn, g.description, g.public_desc
				FROM `#__xgroups` AS g
				WHERE g.type=1
				AND g.published=1
				AND g.discoverability=0" ; $ database -> setQuery ( $ sql ) ; //get all groups $ groups = $ database -> loadObjectList ( ) ; //loop through each group and see if there is a tag match foreach ( $ groups as $ k => $ group ) { //get the groups tags $ gt = new \ Components \ Groups \ Models \ Tags ( $ group -> gidNumber ) ; $ group -> tags = $ gt -> render ( 'string' ) ; $ group -> tags = array_map ( 'trim' , explode ( ',' , $ group -> tags ) ) ; //get common tags $ group -> matches = array_intersect ( $ mytags , $ group -> tags ) ; //remove tags from the group object since its no longer needed unset ( $ group -> tags ) ; //if we dont have a match remove group from return results //or if we are already a member of the group remove from return results if ( count ( $ group -> matches ) < 1 || in_array ( $ group -> gidNumber , $ mygroups ) ) { unset ( $ groups [ $ k ] ) ; } } return $ groups ; }
Gets groups matching tag string

@param   string  $usertags
@param   string  $usergroups
@return  string
Gets groups matching tag string