freenet-router |
Subversion Repositories: |
Compare with Previous - Blame - Download
<?php
namespace Phem\Libraries\Security\Model\Common;
use Phem\Core\Object;
use Phem\Environment\EnvironmentManager;
use Phem\Libraries\Forms\Annotations\Input;
use Phem\Libraries\Forms\Annotations\Select;
use Phem\Libraries\Forms\Annotations\Form;
use Phem\Libraries\Validation\Annotations\Validate;
/**
* @Form(action="", method="POST")
*/
class User extends Object
{
/** @Input */
protected $id;
/**
* @Input(maxlength=24, required=true)
* @Validate(type="ascii")
*/
protected $username;
/**
* @Input(maxlength=32, required=false)
* @Validate(type="alphabet")
*/
protected $name;
/**
* @Input(maxlength=64, required=false)
* @Validate(type="alphabet")
*/
protected $surname;
/**
* @Input(type="password", required=true)
* @Validate(type="password")
*/
protected $password;
/**
* @Input(maxlength=64, required=true)
* @Validate(type="email")
*/
protected $email;
protected $session;
public function getId()
{
return $this->id;
}
public function setId($id)
{
$this->id = $id;
}
public function getUsername()
{
return $this->username;
}
public function setUsername($username)
{
$this->username = $username;
}
public function getName()
{
return $this->name;
}
public function setName($name)
{
$this->name = $name;
}
public function getSurname()
{
return $this->surname;
}
public function setSurname($surname)
{
$this->surname = $surname;
}
public function getPassword()
{
return $this->password;
}
public function setPassword($password)
{
$this->password = $password;
}
public function getEmail()
{
return $this->email;
}
public function setEmail($email)
{
$this->email = $email;
}
public function getSession()
{
return $this->session;
}
public function setSession($session)
{
$this->session = $session;
}
public function getGroups()
{
return EnvironmentManager::getUserManager()->getGroupsOf($this);
}
public function addToGroup(Group $group)
{
EnvironmentManager::getUserManager()->addUserToGroup($group, $this);
}
public function removeFromGroup(Group $group)
{
EnvironmentManager::getUserManager()->removeUserFromGroup($group, $this);
}
public function canTask(Task $task)
{
return EnvironmentManager::getAuthorizationProvider()->canTask($this, $task);
}
public function isMemberOf(Group $group)
{
return EnvironmentManager::getUserManager()->isMemberOf($this, $group);
}
public function delete()
{
EnvironmentManager::getUserManager()->removeUser($this);
}
public function save()
{
if ($this->id == null)
EnvironmentManager::getUserManager()->addUser($this);
else
{
EnvironmentManager::getUserManager()->modifyUser($this);
}
}
}