Made user controller working mostly. Not everything is tested but seems good
This commit is contained in:
@@ -114,6 +114,12 @@ class CommonClubsModelUser extends AbstractCommonClubsModel
|
||||
$this->setValue('password', $hash);
|
||||
}
|
||||
|
||||
public function isPasswordSet()
|
||||
{
|
||||
$password = $this->getValues()['password'];
|
||||
return isset($password) && strlen($password) > 0;
|
||||
}
|
||||
|
||||
public function getPositions()
|
||||
{
|
||||
return $this->fetchAssociatedElements(new CommonClubsModelFactoryUserassoc(), 'userid');
|
||||
@@ -139,7 +145,7 @@ class CommonClubsModelUser extends AbstractCommonClubsModel
|
||||
return true;
|
||||
}
|
||||
|
||||
public function isUsernameSuitable($user)
|
||||
public function isUsernameFree($user)
|
||||
{
|
||||
$factory = new CommonClubsModelFactoryUser();
|
||||
$users = $factory->loadElements(null, null, function($q) use ($user){
|
||||
@@ -167,5 +173,33 @@ class CommonClubsModelUser extends AbstractCommonClubsModel
|
||||
$db->execute();
|
||||
}
|
||||
|
||||
public function dataIsValid()
|
||||
{
|
||||
if(! parent::dataIsValid())
|
||||
return false;
|
||||
|
||||
if(! $this->usernameIsValid())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private function usernameIsValid()
|
||||
{
|
||||
$factory = $this->getFactory();
|
||||
$medb = $factory->loadById($this->getId(), false);
|
||||
|
||||
if($medb !== null && $medb->getUserName() === $this->getUsername())
|
||||
// No change was made
|
||||
return true;
|
||||
|
||||
if(! $this->isUsernameFree($this->getUsername()) )
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user