mirror of
https://github.com/netzbegruenung/circles.git
synced 2024-05-14 17:16:05 +02:00
add multiples mails
Signed-off-by: Maxence Lange <maxence@artificial-owl.com>
This commit is contained in:
parent
f0f1ad3546
commit
53adfebee2
|
@ -180,6 +180,10 @@ class MembersService {
|
||||||
return $this->addGroupMembers($circle, $ident);
|
return $this->addGroupMembers($circle, $ident);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($type === Member::TYPE_USER) {
|
||||||
|
return $this->addMassiveMails($circle, $ident);
|
||||||
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -320,9 +324,8 @@ class MembersService {
|
||||||
}
|
}
|
||||||
|
|
||||||
$tmpContact = $this->userId . ':' . $ident;
|
$tmpContact = $this->userId . ':' . $ident;
|
||||||
try {
|
$result = MiscService::getContactData($tmpContact);
|
||||||
MiscService::getContactData($tmpContact);
|
if (empty($result)) {
|
||||||
} catch (Exception $e) {
|
|
||||||
throw new NoUserException($this->l10n->t("This contact is not available"));
|
throw new NoUserException($this->l10n->t("This contact is not available"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -358,6 +361,31 @@ class MembersService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param Circle $circle
|
||||||
|
* @param string $mails
|
||||||
|
*
|
||||||
|
* @return bool
|
||||||
|
*/
|
||||||
|
private function addMassiveMails(Circle $circle, $mails) {
|
||||||
|
|
||||||
|
foreach (explode(' ', trim($mails)) as $mail) {
|
||||||
|
if (!filter_var($mail, FILTER_VALIDATE_EMAIL)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (explode(' ', trim($mails)) as $mail) {
|
||||||
|
try {
|
||||||
|
$this->addMember($circle->getUniqueId(), $mail, Member::TYPE_MAIL);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* getMember();
|
* getMember();
|
||||||
*
|
*
|
||||||
|
@ -543,4 +571,4 @@ class MembersService {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -141,6 +141,7 @@ class MiscService {
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = array_shift($result);
|
$user = array_shift($result);
|
||||||
|
|
||||||
return $user->getUID();
|
return $user->getUID();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,12 +201,12 @@ class MiscService {
|
||||||
* @return mixed|string
|
* @return mixed|string
|
||||||
*/
|
*/
|
||||||
public static function getContactData($ident) {
|
public static function getContactData($ident) {
|
||||||
list($userId, $contactId) = explode(':', $ident);
|
if (!class_exists(\OCA\DAV\AppInfo\Application::class) || !strpos(':', $ident)) {
|
||||||
|
return [];
|
||||||
if (!class_exists(\OCA\DAV\AppInfo\Application::class)) {
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
list($userId, $contactId) = explode(':', $ident);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
/** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */
|
/** @noinspection PhpUnnecessaryFullyQualifiedNameInspection */
|
||||||
$contactApp = new \OCA\DAV\AppInfo\Application();
|
$contactApp = new \OCA\DAV\AppInfo\Application();
|
||||||
|
@ -217,7 +218,7 @@ class MiscService {
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue