Add the user's cloud id to the vCard
This commit is contained in:
parent
7c8a84e7ac
commit
df6fc6cc70
|
@ -49,6 +49,10 @@ class SyncSystemAddressBook extends Command {
|
|||
->setDescription('Synchronizes users to the system addressbook');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param InputInterface $input
|
||||
* @param OutputInterface $output
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output) {
|
||||
$principalBackend = new Principal(
|
||||
$this->config,
|
||||
|
@ -72,6 +76,7 @@ class SyncSystemAddressBook extends Command {
|
|||
$userId = $user->getUID();
|
||||
$displayName = $user->getDisplayName();
|
||||
$emailAddress = $user->getEMailAddress();
|
||||
$cloudId = $user->getCloudId();
|
||||
$image = $user->getAvatarImage(-1);
|
||||
|
||||
$cardId = "$name:$userId.vcf";
|
||||
|
@ -81,6 +86,7 @@ class SyncSystemAddressBook extends Command {
|
|||
$vCard->add(new Text($vCard, 'UID', $userId));
|
||||
$vCard->add(new Text($vCard, 'FN', $displayName));
|
||||
$vCard->add(new Text($vCard, 'EMAIL', $emailAddress));
|
||||
$vCard->add(new Text($vCard, 'CLOUD', $cloudId));
|
||||
if ($image) {
|
||||
$vCard->add('PHOTO', $image->data(), ['ENCODING' => 'b', 'TYPE' => $image->mimeType()]);
|
||||
}
|
||||
|
|
|
@ -310,20 +310,4 @@ class Helper {
|
|||
\OC::$server->getConfig()->setSystemValue('share_folder', $shareFolder);
|
||||
}
|
||||
|
||||
/**
|
||||
* remove protocol from URL
|
||||
*
|
||||
* @param string $url
|
||||
* @return string
|
||||
*/
|
||||
public static function removeProtocolFromUrl($url) {
|
||||
if (strpos($url, 'https://') === 0) {
|
||||
return substr($url, strlen('https://'));
|
||||
} else if (strpos($url, 'http://') === 0) {
|
||||
return substr($url, strlen('http://'));
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -32,9 +32,7 @@ if (count($matches) > 0 && $matches[1] <= 9) {
|
|||
$isIE8 = true;
|
||||
}
|
||||
|
||||
$uid = \OC::$server->getUserSession()->getUser()->getUID();
|
||||
$server = \OC::$server->getURLGenerator()->getAbsoluteURL('/');
|
||||
$cloudID = $uid . '@' . rtrim(\OCA\Files_Sharing\Helper::removeProtocolFromUrl($server), '/');
|
||||
$cloudID = \OC::$server->getUserSession()->getUser()->getCloudId();
|
||||
$url = 'https://owncloud.org/federation#' . $cloudID;
|
||||
$ownCloudLogoPath = \OC::$server->getURLGenerator()->imagePath('core', 'logo-icon.svg');
|
||||
|
||||
|
|
|
@ -32,60 +32,48 @@ namespace OC\User;
|
|||
use OC\Hooks\Emitter;
|
||||
use OCP\IAvatarManager;
|
||||
use OCP\IImage;
|
||||
use OCP\IURLGenerator;
|
||||
use OCP\IUser;
|
||||
use OCP\IConfig;
|
||||
|
||||
class User implements IUser {
|
||||
/**
|
||||
* @var string $uid
|
||||
*/
|
||||
/** @var string $uid */
|
||||
private $uid;
|
||||
|
||||
/**
|
||||
* @var string $displayName
|
||||
*/
|
||||
/** @var string $displayName */
|
||||
private $displayName;
|
||||
|
||||
/**
|
||||
* @var \OC_User_Interface $backend
|
||||
*/
|
||||
/** @var \OC_User_Interface $backend */
|
||||
private $backend;
|
||||
|
||||
/**
|
||||
* @var bool $enabled
|
||||
*/
|
||||
/** @var bool $enabled */
|
||||
private $enabled;
|
||||
|
||||
/**
|
||||
* @var Emitter|Manager $emitter
|
||||
*/
|
||||
/** @var Emitter|Manager $emitter */
|
||||
private $emitter;
|
||||
|
||||
/**
|
||||
* @var string $home
|
||||
*/
|
||||
/** @var string $home */
|
||||
private $home;
|
||||
|
||||
/**
|
||||
* @var int $lastLogin
|
||||
*/
|
||||
/** @var int $lastLogin */
|
||||
private $lastLogin;
|
||||
|
||||
/**
|
||||
* @var \OCP\IConfig $config
|
||||
*/
|
||||
/** @var \OCP\IConfig $config */
|
||||
private $config;
|
||||
|
||||
/** @var IAvatarManager */
|
||||
private $avatarManager;
|
||||
|
||||
/** @var IURLGenerator */
|
||||
private $urlGenerator;
|
||||
|
||||
/**
|
||||
* @param string $uid
|
||||
* @param \OC_User_Interface $backend
|
||||
* @param \OC\Hooks\Emitter $emitter
|
||||
* @param \OCP\IConfig $config
|
||||
*/
|
||||
public function __construct($uid, $backend, $emitter = null, IConfig $config = null, $avatarManager = null) {
|
||||
public function __construct($uid, $backend, $emitter = null, IConfig $config = null, $avatarManager = null, $urlGenerator = null) {
|
||||
$this->uid = $uid;
|
||||
$this->backend = $backend;
|
||||
$this->emitter = $emitter;
|
||||
|
@ -102,6 +90,9 @@ class User implements IUser {
|
|||
if (is_null($this->avatarManager)) {
|
||||
$this->avatarManager = \OC::$server->getAvatarManager();
|
||||
}
|
||||
if (is_null($this->urlGenerator)) {
|
||||
$this->urlGenerator = \OC::$server->getURLGenerator();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -342,4 +333,30 @@ class User implements IUser {
|
|||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* get the federation cloud id
|
||||
*
|
||||
* @return string
|
||||
* @since 9.0.0
|
||||
*/
|
||||
public function getCloudId() {
|
||||
$uid = $this->getUID();
|
||||
$server = $this->urlGenerator->getAbsoluteURL('/');
|
||||
return $uid . '@' . rtrim( $this->removeProtocolFromUrl($server), '/');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $url
|
||||
* @return string
|
||||
*/
|
||||
private function removeProtocolFromUrl($url) {
|
||||
if (strpos($url, 'https://') === 0) {
|
||||
return substr($url, strlen('https://'));
|
||||
} else if (strpos($url, 'http://') === 0) {
|
||||
return substr($url, strlen('http://'));
|
||||
}
|
||||
|
||||
return $url;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -161,4 +161,12 @@ interface IUser {
|
|||
* @since 9.0.0
|
||||
*/
|
||||
public function getAvatarImage($size);
|
||||
|
||||
/**
|
||||
* get the federation cloud id
|
||||
*
|
||||
* @return string
|
||||
* @since 9.0.0
|
||||
*/
|
||||
public function getCloudId();
|
||||
}
|
||||
|
|
|
@ -102,4 +102,7 @@ class SimpleUserForTesting implements IUser {
|
|||
|
||||
public function getAvatarImage($size) {
|
||||
}
|
||||
|
||||
public function getCloudId() {
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue