mirror of
https://github.com/alchemy-fr/Phraseanet.git
synced 2025-10-14 13:33:14 +00:00
Add ACL & helper methods
This commit is contained in:
@@ -218,6 +218,11 @@ class User
|
||||
*/
|
||||
private $updated;
|
||||
|
||||
/**
|
||||
* @var \ACL
|
||||
*/
|
||||
private $acl;
|
||||
|
||||
/**
|
||||
* @return integer
|
||||
*/
|
||||
@@ -792,4 +797,54 @@ class User
|
||||
|
||||
$this->updated = $updated;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Application $app
|
||||
*
|
||||
* @return \ACL
|
||||
*/
|
||||
public function ACL(Application $app)
|
||||
{
|
||||
if (!$this->acl instanceof \ACL) {
|
||||
$this->acl = new \ACL($this, $app);
|
||||
}
|
||||
|
||||
return $this->acl;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isTemplate()
|
||||
{
|
||||
return null !== $this->modelOf;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return boolean
|
||||
*/
|
||||
public function isSpecial()
|
||||
{
|
||||
return in_array($this->login, array('invite', 'autoregister'));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getDisplayName()
|
||||
{
|
||||
if ($this->isTemplate()) {
|
||||
return sprintf(_('modele %s'), $this->getLogin());
|
||||
}
|
||||
|
||||
if (trim($this->lastName) !== '' || trim($this->firstName) !== '') {
|
||||
return $this->firstName . ('' !== $this->firstName && '' !== $this->lastName ? ' ' : '') . $this->lastName;
|
||||
}
|
||||
|
||||
if (trim($this->email) !== '') {
|
||||
return $this->email;
|
||||
}
|
||||
|
||||
return _('Unnamed user');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user