protected function proceedPerson(array $person)
    {

        // If "Gerrit Code Review" posted some problems, e.g. path conflicts (e.g. https://review.typo3.org/#/c/4553/)
        // there is no person information.
        // Set it here, because otherwise we got empty persons ;)
        if (array_key_exists('name', $person) === false &&
            array_key_exists('email', $person) === false &&
            array_key_exists('username', $person) === false
        ) {

            $person['name'] = 'Unknown (Exporter)';
            $person['email'] = 'mail@example.org';
            $person['username'] = 'Unknown_export_username';
        }

        // Sometimes the person got no name.
        // We have to set a default one
        if (array_key_exists('name', $person) === false) {
            $person['name'] = 'Unknown (Exporter)';
        }

        if (array_key_exists('username', $person) === false) {
            $person['username'] = 'Unknown_export_username';
        }

        // Sometimes you got an action by "Gerrit Code Review".
        // This "system user" does not have a username. Sad, isn`t ?
        // We got a present for him / her. A default username :)
        // e.g. https://review.typo3.org/#/c/4553/
        if ($person['name'] === 'Gerrit Code Review') {
            $person['username'] = 'Gerrit';
        }

        // Sometimes the API does not return an email
        $email = '';
        $emailPerson = false;
        if (array_key_exists('email', $person) !== false) {
            $email = $person['email'];
            $emailPerson = $this->getPersonBy('email', $person['email']);
        }

        if ($emailPerson === false) {

            $personByName = false;
            if ($person['username']) {
                $personByName = $this->getPersonBy('username', $person['username']);

            } elseif ($person['name']) {
                $personByName = $this->getPersonBy('name', $person['name']);
            }

            // If a person does not exist, create a new one.
            if ($personByName === false) {
                $personData = array(
                    'name' => $person['name'],
                    'username' => $person['username']
                );
                $person['id'] = $this->getDatabase()->insertRecord(Database::TABLE_PERSON, $personData);

                $emailData = array(
                    'person' => $person['id'],
                    'email' => $email
                );
                $this->getDatabase()->insertRecord(Database::TABLE_EMAIL, $emailData);

                // Person exists, but has a new e-mail. Just add the e-mail-address to this person
            } else {
                $person['id'] = $personByName['id'];
                $emailData = array(
                    'person' => $personByName['id'],
                    'email' => $email
                );
                $this->getDatabase()->insertRecord(Database::TABLE_EMAIL, $emailData);
            }
        } else {
            $person['id'] = $emailPerson['id'];
        }

        return $person;
    }
protected function proceedPerson(array $person)
    {

        // If "Gerrit Code Review" posted some problems, e.g. path conflicts (e.g. https://review.typo3.org/#/c/4553/)
        // there is no person information.
        // Set it here, because otherwise we got empty persons ;)
        if (array_key_exists('name', $person) === false &&
            array_key_exists('email', $person) === false &&
            array_key_exists('username', $person) === false
        ) {

            $person['name'] = 'Unknown (Exporter)';
            $person['email'] = 'mail@example.org';
            $person['username'] = 'Unknown_export_username';
        }

        // Sometimes the person got no name.
        // We have to set a default one
        if (array_key_exists('name', $person) === false) {
            $person['name'] = 'Unknown (Exporter)';
        }

        if (array_key_exists('username', $person) === false) {
            $person['username'] = 'Unknown_export_username';
        }

        // Sometimes you got an action by "Gerrit Code Review".
        // This "system user" does not have a username. Sad, isn`t ?
        // We got a present for him / her. A default username :)
        // e.g. https://review.typo3.org/#/c/4553/
        if ($person['name'] === 'Gerrit Code Review') {
            $person['username'] = 'Gerrit';
        }

        // Sometimes the API does not return an email
        $email = '';
        $emailPerson = false;
        if (array_key_exists('email', $person) !== false) {
            $email = $person['email'];
            $emailPerson = $this->getPersonBy('email', $person['email']);
        }

        if ($emailPerson === false) {

            $personByName = false;
            if ($person['username']) {
                $personByName = $this->getPersonBy('username', $person['username']);

            } elseif ($person['name']) {
                $personByName = $this->getPersonBy('name', $person['name']);
            }

            // If a person does not exist, create a new one.
            if ($personByName === false) {
                $personData = array(
                    'name' => $person['name'],
                    'username' => $person['username']
                );
                $person['id'] = $this->getDatabase()->insertRecord(Database::TABLE_PERSON, $personData);

                $emailData = array(
                    'person' => $person['id'],
                    'email' => $email
                );
                $this->getDatabase()->insertRecord(Database::TABLE_EMAIL, $emailData);

                // Person exists, but has a new e-mail. Just add the e-mail-address to this person
            } else {
                $person['id'] = $personByName['id'];
                $emailData = array(
                    'person' => $personByName['id'],
                    'email' => $email
                );
                $this->getDatabase()->insertRecord(Database::TABLE_EMAIL, $emailData);
            }
        } else {
            $person['id'] = $emailPerson['id'];
        }

        return $person;
    }
protected function proceedPerson ( array $ person ) { // If "Gerrit Code Review" posted some problems, e.g. path conflicts (e.g. https://review.typo3.org/#/c/4553/) // there is no person information. // Set it here, because otherwise we got empty persons ;) if ( array_key_exists ( 'name' , $ person ) === false && array_key_exists ( 'email' , $ person ) === false && array_key_exists ( 'username' , $ person ) === false ) { $ person [ 'name' ] = 'Unknown (Exporter)' ; $ person [ 'email' ] = 'mail@example.org' ; $ person [ 'username' ] = 'Unknown_export_username' ; } // Sometimes the person got no name. // We have to set a default one if ( array_key_exists ( 'name' , $ person ) === false ) { $ person [ 'name' ] = 'Unknown (Exporter)' ; } if ( array_key_exists ( 'username' , $ person ) === false ) { $ person [ 'username' ] = 'Unknown_export_username' ; } // Sometimes you got an action by "Gerrit Code Review". // This "system user" does not have a username. Sad, isn`t ? // We got a present for him / her. A default username :) // e.g. https://review.typo3.org/#/c/4553/ if ( $ person [ 'name' ] === 'Gerrit Code Review' ) { $ person [ 'username' ] = 'Gerrit' ; } // Sometimes the API does not return an email $ email = '' ; $ emailPerson = false ; if ( array_key_exists ( 'email' , $ person ) !== false ) { $ email = $ person [ 'email' ] ; $ emailPerson = $ this -> getPersonBy ( 'email' , $ person [ 'email' ] ) ; } if ( $ emailPerson === false ) { $ personByName = false ; if ( $ person [ 'username' ] ) { $ personByName = $ this -> getPersonBy ( 'username' , $ person [ 'username' ] ) ; } elseif ( $ person [ 'name' ] ) { $ personByName = $ this -> getPersonBy ( 'name' , $ person [ 'name' ] ) ; } // If a person does not exist, create a new one. if ( $ personByName === false ) { $ personData = array ( 'name' => $ person [ 'name' ] , 'username' => $ person [ 'username' ] ) ; $ person [ 'id' ] = $ this -> getDatabase ( ) -> insertRecord ( Database :: TABLE_PERSON , $ personData ) ; $ emailData = array ( 'person' => $ person [ 'id' ] , 'email' => $ email ) ; $ this -> getDatabase ( ) -> insertRecord ( Database :: TABLE_EMAIL , $ emailData ) ; // Person exists, but has a new e-mail. Just add the e-mail-address to this person } else { $ person [ 'id' ] = $ personByName [ 'id' ] ; $ emailData = array ( 'person' => $ personByName [ 'id' ] , 'email' => $ email ) ; $ this -> getDatabase ( ) -> insertRecord ( Database :: TABLE_EMAIL , $ emailData ) ; } } else { $ person [ 'id' ] = $ emailPerson [ 'id' ] ; } return $ person ; }
Handles the import or update process of a single person.
A person can be determined by name, an e-mail-address or by username.

@param array $person The current person
@return int ID of person
Handles the import or update process of a single person . A person can be determined by name an e - mail - address or by username .