Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions application/models/DbTable/Utilisateur.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,19 @@ public function getUsersWithInformations($group = null)
return $this->fetchAll($select)->toArray();
}

public function isRegistered($login)
public function isRegistered($id_user, $login)
{
$select = $this->select()
->setIntegrityCheck(false)
->from("utilisateur")
->where("USERNAME_UTILISATEUR = ?", $login)
->limit(1);
->where("USERNAME_UTILISATEUR = ?", $login);
if ($id_user !== null) {
$select->where("ID_UTILISATEUR <> ?", $id_user);
}
$select->limit(1);

$result = $this->fetchRow($select);

return ( $result != null ) ? true : false;
return $result != null;
}

public function getId($login)
Expand Down
2 changes: 1 addition & 1 deletion application/services/User.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function save($data, $avatar = null, $id_user = null)
$db->beginTransaction();

try {
if ($id_user === null && $DB_user->isRegistered($data['USERNAME_UTILISATEUR'])) {
if ($DB_user->isRegistered($id_user, $data['USERNAME_UTILISATEUR'])) {
throw new Exception("Nom d'utilisateur déjà enregistré. Veuillez en choisir un autre.");
}
$user = $id_user == null ? $DB_user->createRow() : $DB_user->find($id_user)->current();
Expand Down