Fix user adding
This commit is contained in:
parent
5cf2970219
commit
09bbb789c6
@ -67,7 +67,11 @@ class User extends Storage {
|
||||
}
|
||||
|
||||
public function setEmail($email) {
|
||||
if(filter_var($email, FILTER_VALIDATE_EMAIL) !== false) {
|
||||
if (empty($email)) {
|
||||
$this->email = null;
|
||||
return true;
|
||||
}
|
||||
elseif(filter_var($email, FILTER_VALIDATE_EMAIL) !== false) {
|
||||
$this->email = $email;
|
||||
return true;
|
||||
}
|
||||
@ -77,7 +81,7 @@ class User extends Storage {
|
||||
}
|
||||
|
||||
public function setDisplayName($display_name) {
|
||||
$this->display_name = $display_name;
|
||||
$this->display_name = (!empty($display_name) ? $display_name : NULL);
|
||||
}
|
||||
|
||||
public function setPassword($password) {
|
||||
@ -113,7 +117,7 @@ class User extends Storage {
|
||||
}
|
||||
|
||||
public function setStaySignedInToken($token) {
|
||||
$this->stay_signed_in_token = $token;
|
||||
$this->stay_signed_in_token = (!empty($token) ? $token : NULL);
|
||||
}
|
||||
|
||||
// Password functions
|
||||
@ -177,13 +181,23 @@ class User extends Storage {
|
||||
// (a user = a unique login and display_name)
|
||||
// =========================================
|
||||
public function isUnique() {
|
||||
if($this->load(array('login'=>$this->login)) === false && $this->load(array('display_name'=>$this->display_name)) === false) {
|
||||
if($this->load(array('login'=>$this->login)) === false) {
|
||||
if (!empty($this->display_name)) {
|
||||
if ($this->load(array('display_name'=>$this->display_name)) === false) {
|
||||
return true;
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Maps htmlspecialchars on the class before display
|
||||
// =================================================
|
||||
|
@ -227,7 +227,7 @@
|
||||
$user->setPassword($user->encrypt($_POST['password']));
|
||||
}
|
||||
$user->setAdmin($_POST['admin']);
|
||||
$user->setStaySignedInToken("");
|
||||
$user->setStaySignedInToken(NULL);
|
||||
|
||||
if($user->setEmail($_POST['email']) !== false) {
|
||||
if(!empty($_POST['user_id']) || $user->isUnique()) {
|
||||
@ -1088,7 +1088,7 @@
|
||||
|
||||
// Only keep the invoices which concern the user (as buyer or user in) (only if user != admin)
|
||||
// TODO : Optimize ?
|
||||
if(!$current_user->getAdmin()) {
|
||||
if(!$current_user->getAdmin() && $invoices_list !== false) {
|
||||
foreach($invoices_list as $key=>$invoice) {
|
||||
if($invoice->getBuyer() != $current_user->getId() && !$invoice->getUsersIn()->inUsersIn($current_user->getId())) {
|
||||
unset($invoices_list[$key]);
|
||||
|
@ -35,7 +35,7 @@
|
||||
<tr>
|
||||
<th>{$i18n['users']}</th>
|
||||
<th>{$i18n['you_owe_him']}</th>
|
||||
<th>{$i18n['he_owes_you']}/th>
|
||||
<th>{$i18n['he_owes_you']}</th>
|
||||
</tr>
|
||||
{loop="$users"}
|
||||
{if condition="$balances[$value->getId()][$current_user->getId()] !== 'X' && $balances[$value->getId()][$current_user->getId()] !== '-'"}
|
||||
@ -141,7 +141,7 @@
|
||||
{/loop}
|
||||
</table>
|
||||
{else}
|
||||
<p class="center">{$i18n['no_bills']}.</p>
|
||||
<p class="center">{$i18n['no_bills']}</p>
|
||||
{/if}
|
||||
</div>
|
||||
{include="footer"}
|
||||
|
Loading…
Reference in New Issue
Block a user