zeg1jeux/lib/GchangeUser.class.php

61 lines
1.2 KiB
PHP

<?php
require_once('Gchange.traits.php');
class GchangeUser {
use Locatable, Avatarable;
public $userGchangeId;
public $userName;
public function __construct ($gchangeObject) {
$this->gchangeObject = $gchangeObject;
$this->userGchangeId = $gchangeObject->_id;
if (isset($gchangeObject->found) and $gchangeObject->found == false) {
$this->userName = substr($gchangeObject->_id, 0, 8);
} else {
if (isset($gchangeObject->_source->title)) {
$this->userName = $gchangeObject->_source->title;
}
if (isset($gchangeObject->_source->geoPoint->lat, $gchangeObject->_source->geoPoint->lon)) {
$this->lat = $gchangeObject->_source->geoPoint->lat;
$this->lon = $gchangeObject->_source->geoPoint->lon;
}
if (isset($gchangeObject->_source->avatar->_content) and
!empty($gchangeObject->_source->avatar->_content)) {
$this->avatarImgSrc = 'data:'. $gchangeObject->_source->avatar->_content_type .';base64,' . $gchangeObject->_source->avatar->_content;
}
}
}
public function getUserGchangeId () {
return $this->userGchangeId;
}
public function getUserName () {
return $this->userName;
}
public function jsonify () {
return $this->gchangeObject;
}
}