コード例 #1
0
 /**
  * Returns the profile of the user given
  *
  * @param Users $user
  * @return array
  * @throws InvalidDatabaseOperationException
  */
 private static function getProfileImpl(Users $user)
 {
     $response = array();
     $response['userinfo'] = array();
     $response['problems'] = array();
     $response['userinfo']['username'] = $user->getUsername();
     $response['userinfo']['name'] = $user->getName();
     $response['userinfo']['solved'] = $user->getSolved();
     $response['userinfo']['submissions'] = $user->getSubmissions();
     $response['userinfo']['birth_date'] = is_null($user->getBirthDate()) ? null : strtotime($user->getBirthDate());
     $response['userinfo']['graduation_date'] = is_null($user->getGraduationDate()) ? null : strtotime($user->getGraduationDate());
     $response['userinfo']['scholar_degree'] = $user->getScholarDegree();
     if (!is_null($user->getLanguageId())) {
         $query = LanguagesDAO::getByPK($user->getLanguageId());
         if (!is_null($query)) {
             $response['userinfo']['locale'] = UserController::convertToSupportedLanguage($query->getName());
         }
     }
     try {
         $response['userinfo']['email'] = EmailsDAO::getByPK($user->getMainEmailId())->getEmail();
         $country = CountriesDAO::getByPK($user->getCountryId());
         $response['userinfo']['country'] = is_null($country) ? null : $country->getName();
         $response['userinfo']['country_id'] = $user->getCountryId();
         $state = StatesDAO::getByPK($user->getStateId());
         $response['userinfo']['state'] = is_null($state) ? null : $state->getName();
         $response['userinfo']['state_id'] = $user->getStateId();
         $school = SchoolsDAO::getByPK($user->getSchoolId());
         $response['userinfo']['school_id'] = $user->getSchoolId();
         $response['userinfo']['school'] = is_null($school) ? null : $school->getName();
     } catch (Exception $e) {
         throw new InvalidDatabaseOperationException($e);
     }
     $response['userinfo']['gravatar_92'] = 'https://secure.gravatar.com/avatar/' . md5($response['userinfo']['email']) . '?s=92';
     return $response;
 }