create Access Control Model

This commit is contained in:
2014-10-28 18:24:34 +01:00
parent ec3e08ff79
commit 7fc8b1ca1e
14 changed files with 501 additions and 48 deletions

View File

@@ -39,6 +39,17 @@ class Center
*/
private $id;
/**
*
* @var \Doctrine\Common\Collections\Collection
*/
private $groupCenters;
public function __construct()
{
$this->groupCenters = new \Doctrine\Common\Collections\ArrayCollection();
}
public function getName()
{
return $this->name;
@@ -54,6 +65,17 @@ class Center
{
return $this->id;
}
public function getGroupCenters()
{
return $this->groupCenters;
}
public function addGroupCenter(GroupCenter $groupCenter)
{
$this->groupCenters->add($groupCenter);
return $this;
}
}

118
Entity/GroupCenter.php Normal file
View File

@@ -0,0 +1,118 @@
<?php
/*
* Chill is a suite of a modules, Chill is a software for social workers
* Copyright (C) 2014, Champs Libres Cooperative SCRLFS, <http://www.champs-libres.coop>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
namespace Chill\MainBundle\Entity;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\PermissionsGroup;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
/**
*
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
class GroupCenter
{
/**
*
* @var int
*/
private $id;
/**
*
* @var Center
*/
private $center;
/**
*
* @var Collection
*/
private $users;
/**
*
* @var Collection
*/
private $permissionGroups;
public function __construct()
{
$this->permissionGroups = new ArrayCollection();
$this->users = new ArrayCollection();
}
public function getId()
{
return $this->id;
}
/**
*
* @return Center
*/
public function getCenter()
{
return $this->center;
}
/**
*
* @return PermissionGroup[]
*/
public function getPermissionGroups()
{
return $this->permissionGroups;
}
/**
*
* @param Center $center
* @return \Chill\MainBundle\Entity\GroupCenter
*/
public function setCenter(Center $center)
{
$this->center = $center;
return $this;
}
/**
*
* @param PermissionGroup $permission
* @return \Chill\MainBundle\Entity\GroupCenter
*/
public function addPermissionGroup(PermissionsGroup $permission)
{
$this->permissionGroups->add($permission);
return $this;
}
public function getUsers()
{
return $this->users;
}
}

View File

@@ -29,7 +29,7 @@ use Chill\MainBundle\Entity\RoleScope;
*
* @author Julien Fastré <julien.fastre@champs-libres.coop>
*/
class PermissionGroup
class PermissionsGroup
{
/**
*
@@ -39,7 +39,7 @@ class PermissionGroup
/**
*
* @var array
* @var string
*/
private $name;
@@ -59,6 +59,10 @@ class PermissionGroup
return $this->id;
}
/**
*
* @return string
*/
public function getName()
{
return $this->name;
@@ -69,7 +73,7 @@ class PermissionGroup
return $this->roleScopes;
}
public function setName(array $name)
public function setName($name)
{
$this->name = $name;
return $this;

View File

@@ -2,14 +2,14 @@
namespace Chill\MainBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Security\Core\User\UserInterface;
use Symfony\Component\Security\Core\User\AdvancedUserInterface;
use Doctrine\Common\Collections\Collection;
use Doctrine\Common\Collections\ArrayCollection;
/**
* User
*/
class User implements UserInterface {
class User implements AdvancedUserInterface {
/**
* @var integer
@@ -21,14 +21,43 @@ class User implements UserInterface {
*/
private $username;
/**
*
* @var string
*/
private $password;
private $salt;
/**
*
* @var string
* @internal must be set to null if we use bcrypt
*/
private $salt = null;
/**
*
* @var boolean
*/
private $locked = false;
/**
*
* @var boolean
*/
private $enabled = true;
/**
*
* @var Collection
*/
private $groupCenters;
public function __construct()
{
$this->groupCenters = new ArrayCollection();
}
/**
* Get id
*
@@ -51,16 +80,6 @@ class User implements UserInterface {
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->username;
}
public function __toString() {
return $this->getUsername();
@@ -71,6 +90,10 @@ class User implements UserInterface {
}
/**
*
* @return string
*/
public function getPassword()
{
return $this->password;
@@ -93,7 +116,7 @@ class User implements UserInterface {
function setPassword($password)
{
$this->password = $password;
$this->password = $password;
return $this;
}
@@ -103,6 +126,63 @@ class User implements UserInterface {
return $this;
}
/**
* {@inheritdoc}
*
* @return boolean
*/
public function isAccountNonExpired()
{
return false;
}
/**
* {@inheritdoc}
*
*/
public function isAccountNonLocked()
{
return $this->locked;
}
/**
* {@inheritdoc}
*
* @return boolean
*/
public function isCredentialsNonExpired()
{
return true;
}
/**
* {@inheritdoc}
*
* @return boolean
*/
public function isEnabled()
{
return $this->enabled;
}
/**
*
* @return GroupCenter[]
*/
public function getGroupCenters()
{
return $this->groupCenters;
}
/**
*
* @param \Chill\MainBundle\Entity\GroupCenter $groupCenter
* @return \Chill\MainBundle\Entity\User
*/
public function addGroupCenter(GroupCenter $groupCenter)
{
$this->groupCenters->add($groupCenter);
return $this;
}
}