FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » FUDforum » FUDforum Suggestions » SSO with TYPO3
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Aw: Re: Aw: Re: Aw: Re: SSO with TYPO3 [message #166259 is a reply to message #166258] Mon, 17 October 2011 15:47 Go to previous messageGo to previous message
kaystrobach is currently offline  kaystrobach   
Messages: 28
Registered: May 2006
Location: Bannewitz
Karma:
Junior Member

currently i struggle at the following problem:

my function looks so:

function sso_syncGroups($userID, $groupNames) {
		// iterate
	foreach($groupNames as $groupName) {
			// Use special name
		$groupName = 'SSO: ' . $groupName;
			// Check wether group exists
		$r = db_sab('SELECT id FROM '. $GLOBALS['DBHOST_TBL_PREFIX'] .'groups WHERE name='. _esc($groupName));
		if($r) {
			$groupId = $r->id;
		} else {
			$groupId = ins_m(
				$GLOBALS['DBHOST_TBL_PREFIX'] .'groups',
				'name',
				_esc($groupName)
			);
		}
			// Check wether user is in group and add it
		$r = db_sab('SELECT id FROM '. $GLOBALS['DBHOST_TBL_PREFIX'] .'group_members WHERE group_id='. _esc($groupId) . ' AND user_id=' . _esc($userID));
		if(!$r) {
			ins_m(
				$GLOBALS['DBHOST_TBL_PREFIX'] .'group_members',
				'group_id, user_id',
				array(
					_esc($groupId),
					_esc($userID)
				)
			);
		}
	}
		// remove groups which are removed in external adapter
	$list = '';
	foreach($groupNames as $groupName) {
		if($list !== '') {
			$list.= ', ';
		}
		$list.= _esc($groupName);
	}
	$q = '
		SELECT * 
		FROM '. $GLOBALS['DBHOST_TBL_PREFIX'] .'group_members 
		LEFT JOIN '. $GLOBALS['DBHOST_TBL_PREFIX'] .'groups ON '. $GLOBALS['DBHOST_TBL_PREFIX'] .'group_members.group_id = fud_groups.id
		WHERE '. $GLOBALS['DBHOST_TBL_PREFIX'] .'group_members.user_id = ' . _esc($userID) . '
		AND '. $GLOBALS['DBHOST_TBL_PREFIX'] .'groups.name NOT IN (' . $list . ')
		AND '. $GLOBALS['DBHOST_TBL_PREFIX'] .'groups.name LIKE "SSO:%"
	';
	$groupsToRemove = uq($q);
	if(method_exists($groupsToRemove, 'fetchAll')) {
		$groupsToRemove = $groupsToRemove->fetchAll(PDO::FETCH_COLUMN);
		foreach($groupsToRemove as $group) {
			echo $group;
			uq('DELETE FROM '. $GLOBALS['DBHOST_TBL_PREFIX'] .'group_members WHERE id = ' . _esc($group->id));
		}
	}
}


Using external_fud_login($User_ID) afterwards throws the following sql error - any idea?

HY000: Cannot execute queries while other unbuffered queries are active.


Thanks in advice - regards
Kay
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: RSS 2 Topic
Next Topic: list all smilies on the same page
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Wed Nov 27 00:22:45 GMT 2024

Total time taken to generate the page: 0.03961 seconds