src/User.php
public function socialLink($provider, $providerKey, $userid = null)
	{
		$this->debug->groupCollapsed(__METHOD__);
		if ($userid === null) {
			$userid = $this->userid;
		}
		$vals = array(
			'userid'		=> $userid,
			'provider'		=> strtolower($provider),
			'providerkey'	=> $providerKey,
		);
		/*
			search if social is linked to another account
		*/
		$where = array(
			'provider'		=> strtolower($provider),
			'providerkey'	=> $providerKey,
		);
		/*
		foreach ($where as $k => $v) {
			unset($where[$k]);
			$where[] = '`'.$k.'`='.$this->db->quoteValue($v);
		}
		$where = implode(' AND ', $where);
		*/
		$found = $this->db->query('SELECT * FROM `user_social` '.$this->db->buildWhere($where))[0];
		if ($found) {
			$this->socialUnlink($found[0]['provider'], $found[0]['providerkey']);
		}
		$this->db->rowMan('user_social', $vals);
		$this->log('socialLink', $userid, array(
			'provider'		=> strtolower($provider),
			'providerKey'	=> $providerKey,
		));
		$this->debug->groupEnd();
		return;
	}
public function socialLink($provider, $providerKey, $userid = null)
	{
		$this->debug->groupCollapsed(__METHOD__);
		if ($userid === null) {
			$userid = $this->userid;
		}
		$vals = array(
			'userid'		=> $userid,
			'provider'		=> strtolower($provider),
			'providerkey'	=> $providerKey,
		);
		/*
			search if social is linked to another account
		*/
		$where = array(
			'provider'		=> strtolower($provider),
			'providerkey'	=> $providerKey,
		);
		/*
		foreach ($where as $k => $v) {
			unset($where[$k]);
			$where[] = '`'.$k.'`='.$this->db->quoteValue($v);
		}
		$where = implode(' AND ', $where);
		*/
		$found = $this->db->query('SELECT * FROM `user_social` '.$this->db->buildWhere($where))[0];
		if ($found) {
			$this->socialUnlink($found[0]['provider'], $found[0]['providerkey']);
		}
		$this->db->rowMan('user_social', $vals);
		$this->log('socialLink', $userid, array(
			'provider'		=> strtolower($provider),
			'providerKey'	=> $providerKey,
		));
		$this->debug->groupEnd();
		return;
	}
public function socialLink ( $ provider , $ providerKey , $ userid = null ) { $ this -> debug -> groupCollapsed ( __METHOD__ ) ; if ( $ userid === null ) { $ userid = $ this -> userid ; } $ vals = array ( 'userid' => $ userid , 'provider' => strtolower ( $ provider ) , 'providerkey' => $ providerKey , ) ; /*
			search if social is linked to another account
		*/ $ where = array ( 'provider' => strtolower ( $ provider ) , 'providerkey' => $ providerKey , ) ; /*
		foreach ($where as $k => $v) {
			unset($where[$k]);
			$where[] = '`'.$k.'`='.$this->db->quoteValue($v);
		}
		$where = implode(' AND ', $where);
		*/ $ found = $ this -> db -> query ( 'SELECT * FROM `user_social` ' . $ this -> db -> buildWhere ( $ where ) ) [ 0 ] ; if ( $ found ) { $ this -> socialUnlink ( $ found [ 0 ] [ 'provider' ] , $ found [ 0 ] [ 'providerkey' ] ) ; } $ this -> db -> rowMan ( 'user_social' , $ vals ) ; $ this -> log ( 'socialLink' , $ userid , array ( 'provider' => strtolower ( $ provider ) , 'providerKey' => $ providerKey , ) ) ; $ this -> debug -> groupEnd ( ) ; return ; }
Link user to a authentication provider

@param string  $provider    Facebook, Twiter, etc
@param string  $providerKey UID provided by provider
@param integer $userid      optional

@todo check if providerKey linked to another account... if so remove that linkage

@return void
Link user to a authentication provider