Simply the code.

This commit is contained in:
Juan Basso 2011-03-01 19:58:04 -03:00
parent 03b4ce070b
commit 30dced741d

View file

@ -375,25 +375,20 @@ class CakeEmail {
throw new SocketException(__('Invalid email: "%s"', $email)); throw new SocketException(__('Invalid email: "%s"', $email));
} }
if ($name === null) { if ($name === null) {
$this->{$varName} = array($email => $email); $name = $email;
} else {
$this->{$varName} = array($email => $name);
} }
$this->{$varName} = array($email => $name);
return; return;
} }
$list = array(); $list = array();
foreach ($email as $key => $value) { foreach ($email as $key => $value) {
if (is_int($key)) { if (is_int($key)) {
if (!Validation::email($value)) { $key = $value;
throw new SocketException(__('Invalid email: "%s"', $value));
}
$list[$value] = $value;
} else {
if (!Validation::email($key)) {
throw new SocketException(__('Invalid email: "%s"', $key));
}
$list[$key] = $value;
} }
if (!Validation::email($key)) {
throw new SocketException(__('Invalid email: "%s"', $key));
}
$list[$key] = $value;
} }
$this->{$varName} = $list; $this->{$varName} = $list;
} }
@ -431,25 +426,20 @@ class CakeEmail {
throw new SocketException(__('Invalid email: "%s"', $email)); throw new SocketException(__('Invalid email: "%s"', $email));
} }
if ($name === null) { if ($name === null) {
$this->{$varName}[$email] = $email; $name = $email;
} else {
$this->{$varName}[$email] = $name;
} }
$this->{$varName}[$email] = $name;
return; return;
} }
$list = array(); $list = array();
foreach ($email as $key => $value) { foreach ($email as $key => $value) {
if (is_int($key)) { if (is_int($key)) {
if (!Validation::email($value)) { $key = $value;
throw new SocketException(__('Invalid email: "%s"', $value));
}
$list[$value] = $value;
} else {
if (!Validation::email($key)) {
throw new SocketException(__('Invalid email: "%s"', $key));
}
$list[$key] = $value;
} }
if (!Validation::email($key)) {
throw new SocketException(__('Invalid email: "%s"', $key));
}
$list[$key] = $value;
} }
$this->{$varName} = array_merge($this->{$varName}, $list); $this->{$varName} = array_merge($this->{$varName}, $list);
} }