jablonka.czprosek.czf

freenet-router

Subversion Repositories:
[/] [trunk/] [freenet-router/] [var/] [www/] [freenet-router/] [Framework/] [Libraries/] [Security/] [Model/] [Common/] [Group.php] - Rev 2

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\Form;
use Phem\Libraries\Forms\Annotations\Group as AnnotationGroup;
use Phem\Libraries\Forms\Annotations\Input;
use Phem\Libraries\Validation\Annotations\Validate;

/**
 * @Form(defaultGroup="newController")
 */
class Group extends Object
{

    /**
     * @Input(caption="Id", type="text", maxlength=5)
     */
    protected $id;
    /**
     * @Input(caption="NĂĄzev skupiny", type="text", maxlength=32)
     * @Validate(type="alphanumericext")
     */
    protected $name;
    /**
     * @Input(caption="Popisek", type="text", maxlength=32)
     * @Validate(type="alphanumericext")
     */
    protected $description;

    public function getId()
    {
        return $this->id;
    }

    public function setId($id)
    {
        $this->id = $id;
    }

    public function getName()
    {
        return $this->name;
    }

    public function setName($name)
    {
        $this->name = $name;
    }

    public function getDescription()
    {
        return $this->description;
    }

    public function setDescription($description)
    {
        $this->description = $description;
    }
    
    public function save()
    {
        if ($this->id == null)
            EnvironmentManager::getUserManager()->addGroup($this);
        else
        {
            EnvironmentManager::getUserManager()->modifyGroup($this);
        }
    }
    
    public function delete()
    {
        EnvironmentManager::getUserManager()->removeGroup($this);
    }
    
    public function addUser(User $user)
    {
        EnvironmentManager::getUserManager()->addUserToGroup($this, $user);
    }
    
    public function removeUser(User $user)
    {
        EnvironmentManager::getUserManager()->removeUserFromGroup($this, $user);
    }
    
    public function getTasks()
    {
        return EnvironmentManager::getPermissionManager()->getTasks($this);
    }

}

Powered by WebSVN 2.2.1