class Converter {
- public function __construct() {
- }
-
+ /**
+ * @param IUser $user
+ * @return VCard
+ */
public function createCardFromUser(IUser $user) {
$uid = $user->getUID();
return $vCard;
}
+ /**
+ * @param VCard $vCard
+ * @param IUser $user
+ * @return bool
+ */
public function updateCard(VCard $vCard, IUser $user) {
$uid = $user->getUID();
$displayName = $user->getDisplayName();
return $updated;
}
+ /**
+ * @param VCard $vCard
+ * @param string $name
+ * @param string|IImage $newValue
+ * @return bool
+ */
private function propertyNeedsUpdate(VCard $vCard, $name, $newValue) {
if (is_null($newValue)) {
return false;
* @param string $uid
* @param \OC_User_Interface $backend
* @param \OC\Hooks\Emitter $emitter
- * @param \OCP\IConfig $config
+ * @param IConfig|null $config
+ * @param IURLGenerator $urlGenerator
*/
- public function __construct($uid, $backend, $emitter = null, IConfig $config = null, $avatarManager = null, $urlGenerator = null) {
+ public function __construct($uid, $backend, $emitter = null, IConfig $config = null, $urlGenerator = null) {
$this->uid = $uid;
$this->backend = $backend;
$this->emitter = $emitter;
$this->config = $config;
- $this->avatarManager = $avatarManager;
$this->urlGenerator = $urlGenerator;
if ($this->config) {
$enabled = $this->config->getUserValue($uid, 'core', 'enabled', 'true');
$this->enabled = true;
$this->lastLogin = \OC::$server->getConfig()->getUserValue($uid, 'login', 'lastLogin', 0);
}
- if (is_null($this->avatarManager)) {
- $this->avatarManager = \OC::$server->getAvatarManager();
- }
if (is_null($this->urlGenerator)) {
$this->urlGenerator = \OC::$server->getURLGenerator();
}
}
/**
- * get the displayname for the user, if no specific displayname is set it will fallback to the user id
+ * get the display name for the user, if no specific display name is set it will fallback to the user id
*
* @return string
*/
* @since 9.0.0
*/
public function getAvatarImage($size) {
+ // delay the initialization
+ if (is_null($this->avatarManager)) {
+ $this->avatarManager = \OC::$server->getAvatarManager();
+ }
+
$avatar = $this->avatarManager->getAvatar($this->uid);
$image = $avatar->get(-1);
if ($image) {
->method('getAbsoluteURL')
->withAnyParameters()
->willReturn('http://localhost:8888/owncloud');
- $user = new \OC\User\User('foo', $backend, null, null, null, $urlGenerator);
+ $user = new \OC\User\User('foo', $backend, null, null, $urlGenerator);
$this->assertEquals("foo@localhost:8888/owncloud", $user->getCloudId());
}
}