public function findOrCreateMember($usrSettings = array()) {

		$defaults = array(
			/**
			 * Link this identity to any newly discovered member.
			 */
			'linkOnMatch' => true,
			/**
			 * True, false, or an array of fields to overwrite if we merge data.
			 * Exception to this rule is overwriteEmail, which takes precedence.
			 */
			'overwriteExistingFields' => false,
			/**
			 * Overwrite the email field if it's different. Effectively changes
			 * the Member login details, so it's set to false for now.
			 */
			'overwriteEmail' => false,
		);

		$settings = array_merge($defaults, $usrSettings);

		if($this->isInDB()) {
			$member = $this->Member();
			if($member->exists()) {
				return $member;
			}
		}

		$record = $this->getMemberRecordFromAuth();

		if(empty($record['Email'])) {
			$member = new Member();
		}
		else {
			$member = Member::get()->filter('Email', $record['Email'])->first();

			if(!$member) {
				$member = new Member();
			}
		}

		if($settings['linkOnMatch'] && $member->isInDB()) {
			$this->MemberID = $member->ID;
		}

		// If this is a new member, give it everything we have.
		if(!$member->isInDB()) {
			$member->update($record);
		}
		// If not, we update it carefully using the settings described above.
		else {
			$overwrite = $settings['overwriteExistingFields'];
			$overwriteEmail = $settings['overwriteEmail'];
			$fieldsToWrite = array();

			// If overwrite is true, take everything (subtract Email later)
			if($overwrite === true) {
				$fieldsToWrite = $record;
			}
			else if(is_array($overwrite)) {
				$fieldsToWrite = array_intersect_key($record, ArrayLib::valuekey($overwrite));
			}
			// If false then fieldsToWrite remains empty, let's coast it out.

			// Subtract email if setting is not precisely true:
			if($overwriteEmail !== true && isset($fieldsToWrite['Email'])) {
				unset($fieldsToWrite['Email']);
			}

			// Boom, we're so done.
			$member->update($fieldsToWrite);
		}

		return $member;
	}
public function findOrCreateMember($usrSettings = array()) {

		$defaults = array(
			/**
			 * Link this identity to any newly discovered member.
			 */
			'linkOnMatch' => true,
			/**
			 * True, false, or an array of fields to overwrite if we merge data.
			 * Exception to this rule is overwriteEmail, which takes precedence.
			 */
			'overwriteExistingFields' => false,
			/**
			 * Overwrite the email field if it's different. Effectively changes
			 * the Member login details, so it's set to false for now.
			 */
			'overwriteEmail' => false,
		);

		$settings = array_merge($defaults, $usrSettings);

		if($this->isInDB()) {
			$member = $this->Member();
			if($member->exists()) {
				return $member;
			}
		}

		$record = $this->getMemberRecordFromAuth();

		if(empty($record['Email'])) {
			$member = new Member();
		}
		else {
			$member = Member::get()->filter('Email', $record['Email'])->first();

			if(!$member) {
				$member = new Member();
			}
		}

		if($settings['linkOnMatch'] && $member->isInDB()) {
			$this->MemberID = $member->ID;
		}

		// If this is a new member, give it everything we have.
		if(!$member->isInDB()) {
			$member->update($record);
		}
		// If not, we update it carefully using the settings described above.
		else {
			$overwrite = $settings['overwriteExistingFields'];
			$overwriteEmail = $settings['overwriteEmail'];
			$fieldsToWrite = array();

			// If overwrite is true, take everything (subtract Email later)
			if($overwrite === true) {
				$fieldsToWrite = $record;
			}
			else if(is_array($overwrite)) {
				$fieldsToWrite = array_intersect_key($record, ArrayLib::valuekey($overwrite));
			}
			// If false then fieldsToWrite remains empty, let's coast it out.

			// Subtract email if setting is not precisely true:
			if($overwriteEmail !== true && isset($fieldsToWrite['Email'])) {
				unset($fieldsToWrite['Email']);
			}

			// Boom, we're so done.
			$member->update($fieldsToWrite);
		}

		return $member;
	}
public function findOrCreateMember ( $ usrSettings = array ( ) ) { $ defaults = array ( /**
			 * Link this identity to any newly discovered member.
			 */ 'linkOnMatch' => true , /**
			 * True, false, or an array of fields to overwrite if we merge data.
			 * Exception to this rule is overwriteEmail, which takes precedence.
			 */ 'overwriteExistingFields' => false , /**
			 * Overwrite the email field if it's different. Effectively changes
			 * the Member login details, so it's set to false for now.
			 */ 'overwriteEmail' => false , ) ; $ settings = array_merge ( $ defaults , $ usrSettings ) ; if ( $ this -> isInDB ( ) ) { $ member = $ this -> Member ( ) ; if ( $ member -> exists ( ) ) { return $ member ; } } $ record = $ this -> getMemberRecordFromAuth ( ) ; if ( empty ( $ record [ 'Email' ] ) ) { $ member = new Member ( ) ; } else { $ member = Member :: get ( ) -> filter ( 'Email' , $ record [ 'Email' ] ) -> first ( ) ; if ( ! $ member ) { $ member = new Member ( ) ; } } if ( $ settings [ 'linkOnMatch' ] && $ member -> isInDB ( ) ) { $ this -> MemberID = $ member -> ID ; } // If this is a new member, give it everything we have. if ( ! $ member -> isInDB ( ) ) { $ member -> update ( $ record ) ; } // If not, we update it carefully using the settings described above. else { $ overwrite = $ settings [ 'overwriteExistingFields' ] ; $ overwriteEmail = $ settings [ 'overwriteEmail' ] ; $ fieldsToWrite = array ( ) ; // If overwrite is true, take everything (subtract Email later) if ( $ overwrite === true ) { $ fieldsToWrite = $ record ; } else if ( is_array ( $ overwrite ) ) { $ fieldsToWrite = array_intersect_key ( $ record , ArrayLib :: valuekey ( $ overwrite ) ) ; } // If false then fieldsToWrite remains empty, let's coast it out. // Subtract email if setting is not precisely true: if ( $ overwriteEmail !== true && isset ( $ fieldsToWrite [ 'Email' ] ) ) { unset ( $ fieldsToWrite [ 'Email' ] ) ; } // Boom, we're so done. $ member -> update ( $ fieldsToWrite ) ; } return $ member ; }
Finds a member based on this identity. Searches existing records before
creating a new Member object.
Note that this method does not write anything, merely sets everything up.
@param array $usrSettings A map of settings because there are so many.
@return Member
Finds a member based on this identity . Searches existing records before creating a new Member object . Note that this method does not write anything merely sets everything up .