fixes
This commit is contained in:
Родитель
44288900c4
Коммит
a439a12227
|
@ -30,6 +30,9 @@ class Contact extends UserGroupClass {
|
|||
public const TYPE = 'contact';
|
||||
public const ICON = 'icon-mail';
|
||||
|
||||
/** @var Array */
|
||||
private $contact;
|
||||
|
||||
/**
|
||||
* User constructor.
|
||||
* @param $id
|
||||
|
|
|
@ -28,6 +28,8 @@ class User extends UserGroupClass {
|
|||
public const TYPE = 'user';
|
||||
public const ICON = 'icon-user';
|
||||
|
||||
private $user;
|
||||
|
||||
/**
|
||||
* User constructor.
|
||||
* @param $id
|
||||
|
@ -38,13 +40,12 @@ class User extends UserGroupClass {
|
|||
parent::__construct($id, self::TYPE);
|
||||
$this->icon = self::ICON;
|
||||
$this->isNoUser = false;
|
||||
$this->description = \OC::$server->getL10N('polls')->t('User');
|
||||
|
||||
$this->user = \OC::$server->getUserManager()->get($this->id);
|
||||
$this->language = \OC::$server->getConfig()->getUserValue($this->id, 'core', 'lang');
|
||||
|
||||
$this->displayName = \OC::$server->getUserManager()->get($this->id)->getDisplayName();
|
||||
$this->description = \OC::$server->getL10N('polls')->t('User');
|
||||
$this->displayName = $this->user->getDisplayName();
|
||||
$this->emailAddress = $this->user->getEMailAddress();
|
||||
$this->language = \OC::$server->getConfig()->getUserValue($this->id, 'core', 'lang');
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -28,7 +28,6 @@ class UserGroupClass implements \JsonSerializable {
|
|||
public const TYPE_PUBLIC = 'public';
|
||||
public const TYPE_EXTERNAL = 'external';
|
||||
|
||||
/** @var IL10N */
|
||||
private $l10n;
|
||||
|
||||
/** @var string */
|
||||
|
@ -55,11 +54,11 @@ class UserGroupClass implements \JsonSerializable {
|
|||
/** @var string */
|
||||
protected $icon = '';
|
||||
|
||||
/** @var string */
|
||||
protected $isNoUser = '';
|
||||
/** @var boolean */
|
||||
protected $isNoUser = true;
|
||||
|
||||
/** @var string */
|
||||
protected $categories = '';
|
||||
/** @var string[] */
|
||||
protected $categories = [];
|
||||
|
||||
/**
|
||||
* User constructor.
|
||||
|
@ -80,7 +79,6 @@ class UserGroupClass implements \JsonSerializable {
|
|||
$this->language = $language;
|
||||
$this->icon = 'icon-share';
|
||||
$this->l10n = \OC::$server->getL10N('polls');
|
||||
$this->isNoUser = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -123,41 +123,7 @@ class ShareService {
|
|||
}
|
||||
|
||||
$this->share = new Share();
|
||||
|
||||
switch ($type) {
|
||||
case Group::TYPE:
|
||||
$share = new Group($userId);
|
||||
break;
|
||||
case Circle::TYPE:
|
||||
$share = new Circle($userId);
|
||||
break;
|
||||
case Contact::TYPE:
|
||||
$share = new Contact($userId);
|
||||
break;
|
||||
case ContactGroup::TYPE:
|
||||
$share = new ContactGroup($userId);
|
||||
break;
|
||||
case User::TYPE:
|
||||
$share = new User($userId);
|
||||
break;
|
||||
case Email::TYPE:
|
||||
$share = new Email($userId, $emailAddress);
|
||||
break;
|
||||
case UserGroupClass::TYPE_PUBLIC:
|
||||
break;
|
||||
default:
|
||||
throw new InvalidShareType('Invalid share type (' . $type . ')');
|
||||
}
|
||||
|
||||
$this->share->setPollId($pollId);
|
||||
if ($type = UserGroupClass::TYPE_PUBLIC) {
|
||||
$this->share->setType(UserGroupClass::TYPE_PUBLIC);
|
||||
} else {
|
||||
$this->share->setType($share->getType());
|
||||
$this->share->setUserId($share->getId());
|
||||
$this->share->setDisplayName($share->getDisplayName());
|
||||
$this->share->setUserEmail($share->getEmailAddress());
|
||||
}
|
||||
$this->share->setInvitationSent(0);
|
||||
$this->share->setToken(\OC::$server->getSecureRandom()->generate(
|
||||
16,
|
||||
|
@ -166,6 +132,39 @@ class ShareService {
|
|||
ISecureRandom::CHAR_UPPER
|
||||
));
|
||||
|
||||
|
||||
if ($type === UserGroupClass::TYPE_PUBLIC) {
|
||||
$this->share->setType(UserGroupClass::TYPE_PUBLIC);
|
||||
} else {
|
||||
switch ($type) {
|
||||
case Group::TYPE:
|
||||
$share = new Group($userId);
|
||||
break;
|
||||
case Circle::TYPE:
|
||||
$share = new Circle($userId);
|
||||
break;
|
||||
case Contact::TYPE:
|
||||
$share = new Contact($userId);
|
||||
break;
|
||||
case ContactGroup::TYPE:
|
||||
$share = new ContactGroup($userId);
|
||||
break;
|
||||
case User::TYPE:
|
||||
$share = new User($userId);
|
||||
break;
|
||||
case Email::TYPE:
|
||||
$share = new Email($userId, $emailAddress);
|
||||
break;
|
||||
default:
|
||||
throw new InvalidShareType('Invalid share type (' . $type . ')');
|
||||
}
|
||||
|
||||
$this->share->setType($share->getType());
|
||||
$this->share->setUserId($share->getId());
|
||||
$this->share->setDisplayName($share->getDisplayName());
|
||||
$this->share->setUserEmail($share->getEmailAddress());
|
||||
}
|
||||
|
||||
return $this->shareMapper->insert($this->share);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче