<commit_before><?php
/**
 * Litus is a project by a group of students from the KU Leuven. The goal is to create
 * various applications to support the IT needs of student unions.
 *
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 *
 * @license http://litus.cc/LICENSE
 */

namespace ApiBundle\Controller;

use CommonBundle\Entity\User\Person,
    CommonBundle\Entity\User\Person\Academic,
    Zend\View\Model\ViewModel;

/**
 * AuthController
 *
 * @author <NAME> <<EMAIL>>
 */
class AuthController extends \ApiBundle\Component\Controller\ActionController\ApiController
{
    public function personAction()
    {
        $this->initJson();

        if (!($person = $this->getPersonEntity())) {
            return $this->error(404, 'The person was not found');
        }

        $result = array(
            'username' => $person->getUsername(),
            'full_name' => $person->getFullName(),
            'email' => $person->getEmail(),
        );

        $academic = $this->getEntityManager()
            ->getRepository('CommonBundle\Entity\User\Person\Academic')
            ->findOneById($person->getId());

        if (null !== $academic) {
            $result['university_status'] = (null !== $academic->getUniversityStatus($this->getCurrentAcademicYear()))
                ? $academic->getUniversityStatus($this->getCurrentAcademicYear())->getStatus()
                : '';
            $result['organization_status'] = (null !== $academic->getOrganizationStatus($this->getCurrentAcademicYear(true)))
                ? $academic->getOrganizationStatus($this->getCurrentAcademicYear(true))->getStatus()
                : '';
            $result['in_workinggroup'] = (null !== $academic->isInWorkingGroup())
                ? $academic->isInWorkingGroup()
                : false;
        }

        return new ViewModel(
            array(
                'result' => (object) $result,
            )
        );
    }

    public function getPersonAction()
    {
        return $this->personAction();
    }<commit_msg>added corporate to person api<commit_after><?php
/**
 * Litus is a project by a group of students from the KU Leuven. The goal is to create
 * various applications to support the IT needs of student unions.
 *
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 *
 * @license http://litus.cc/LICENSE
 */

namespace ApiBundle\Controller;

use CommonBundle\Entity\User\Person,
    CommonBundle\Entity\User\Person\Academic,
    Zend\View\Model\ViewModel;

/**
 * AuthController
 *
 * @author <NAME> <<EMAIL>>
 */
class AuthController extends \ApiBundle\Component\Controller\ActionController\ApiController
{
    public function personAction()
    {
        $this->initJson();

        if (!($person = $this->getPersonEntity())) {
            return $this->error(404, 'The person was not found');
        }
        print_r("Person found");
        $result = array(
            'username' => $person->getUsername(),
            'full_name' => $person->getFullName(),
            'email' => $person->getEmail(),
        );

        $academic = $this->getEntityManager()
            ->getRepository('CommonBundle\Entity\User\Person\Academic')
            ->findOneById($person->getId());

        $corporate = $this->getEntityManager()
            ->getRepository('BrBundle\Entity\User\Person\Corporate')
            ->findOneById($person->getId());

        if (null !== $academic) {
            $result['university_status'] = (null !== $academic->getUniversityStatus($this->getCurrentAcademicYear()))
                ? $academic->getUniversityStatus($this->getCurrentAcademicYear())->getStatus()
                : '';
            $result['organization_status'] = (null !== $academic->getOrganizationStatus($this->getCurrentAcademicYear(true)))
                ? $academic->getOrganizationStatus($this->getCurrentAcademicYear(true))->getStatus()
                : '';
            $result['in_workinggroup'] = (null !== $academic->isInWorkingGroup())
                ? $academic->isInWorkingGroup()
                : false;
        }

        if (null !== $corporate) {
            $result['corporate_id'] = (null !== $corporate->getCompany())
                ? $academic->getCompany()->getId()
                : "-1";
        }

        return new ViewModel(
            array(
                'result' => (object) $result,
            )
        );
    }

    public function getPersonAction()
    {
        return $this->personAction();
    }
{'fraction_non_alphanumeric': 0.16562939168841598, 'fraction_numerical': 0.0014053402931138326, 'mean_word_length': 2.533333333333333, 'pattern_counts': {'":': 0, '<': 77, '<?xml version=': 0, '>': 136, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7141906', 'n_tokens_mistral': 1476, 'n_tokens_neox': 1429, 'n_words': 282}