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