mirror of
https://github.com/Icinga/icingaweb2.git
synced 2025-07-27 07:44:04 +02:00
User: Allow to unset an email and return $this in all setters
$email is optional in the constructor and so should be when calling its setter.
This commit is contained in:
parent
7d177d8712
commit
22feb4b3fd
@ -143,10 +143,13 @@ class User
|
|||||||
* Setter for preferences
|
* Setter for preferences
|
||||||
*
|
*
|
||||||
* @param Preferences $preferences
|
* @param Preferences $preferences
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setPreferences(Preferences $preferences)
|
public function setPreferences(Preferences $preferences)
|
||||||
{
|
{
|
||||||
$this->preferences = $preferences;
|
$this->preferences = $preferences;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -177,10 +180,13 @@ class User
|
|||||||
* Set the groups this user belongs to
|
* Set the groups this user belongs to
|
||||||
*
|
*
|
||||||
* @param array $groups
|
* @param array $groups
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setGroups(array $groups)
|
public function setGroups(array $groups)
|
||||||
{
|
{
|
||||||
$this->groups = $groups;
|
$this->groups = $groups;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -287,6 +293,8 @@ class User
|
|||||||
* Setter for username
|
* Setter for username
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setUsername($name)
|
public function setUsername($name)
|
||||||
{
|
{
|
||||||
@ -302,6 +310,8 @@ class User
|
|||||||
$this->domain = null;
|
$this->domain = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -318,10 +328,13 @@ class User
|
|||||||
* Setter for firstname
|
* Setter for firstname
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setFirstname($name)
|
public function setFirstname($name)
|
||||||
{
|
{
|
||||||
$this->firstname = $name;
|
$this->firstname = $name;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -338,10 +351,13 @@ class User
|
|||||||
* Setter for lastname
|
* Setter for lastname
|
||||||
*
|
*
|
||||||
* @param string $name
|
* @param string $name
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setLastname($name)
|
public function setLastname($name)
|
||||||
{
|
{
|
||||||
$this->lastname = $name;
|
$this->lastname = $name;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -359,15 +375,20 @@ class User
|
|||||||
*
|
*
|
||||||
* @param string $mail
|
* @param string $mail
|
||||||
*
|
*
|
||||||
|
* @return $this
|
||||||
|
*
|
||||||
* @throws InvalidArgumentException When an invalid mail is provided
|
* @throws InvalidArgumentException When an invalid mail is provided
|
||||||
*/
|
*/
|
||||||
public function setEmail($mail)
|
public function setEmail($mail)
|
||||||
{
|
{
|
||||||
if (filter_var($mail, FILTER_VALIDATE_EMAIL)) {
|
if ($mail !== null && !filter_var($mail, FILTER_VALIDATE_EMAIL)) {
|
||||||
$this->email = $mail;
|
throw new InvalidArgumentException(
|
||||||
} else {
|
sprintf('Invalid mail given for user %s: %s', $this->getUsername(), $mail)
|
||||||
throw new InvalidArgumentException('Invalid mail given for user ' . $this->getUsername() . ': $mail');
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->email = $mail;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -431,10 +452,13 @@ class User
|
|||||||
*
|
*
|
||||||
* @param string $key
|
* @param string $key
|
||||||
* @param string $value
|
* @param string $value
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setAdditional($key, $value)
|
public function setAdditional($key, $value)
|
||||||
{
|
{
|
||||||
$this->additionalInformation[$key] = $value;
|
$this->additionalInformation[$key] = $value;
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -474,10 +498,13 @@ class User
|
|||||||
*
|
*
|
||||||
* @param string $username
|
* @param string $username
|
||||||
* @param string $field
|
* @param string $field
|
||||||
|
*
|
||||||
|
* @return $this
|
||||||
*/
|
*/
|
||||||
public function setExternalUserInformation($username, $field)
|
public function setExternalUserInformation($username, $field)
|
||||||
{
|
{
|
||||||
$this->externalUserInformation = array($username, $field);
|
$this->externalUserInformation = array($username, $field);
|
||||||
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user