12345678910111213141516171819202122232425262728293031323334353637 |
- <?php
- class UserGroup extends DBObject {
- public $Permissions=array();
-
- public function __construct($id) {
- parent::__construct("user_groups", "group_id", $id);
- $permissions=explode(",", $this->GroupPermissions);
- foreach ($permissions as $p)
- $this->Permissions[]=new Permission($p);
-
-
- // Hack for MySQL on Linux
- if ($this->GroupIsAdmin!='1' && $this->GroupIsAdmin!='0')
- $this->GroupIsAdmin=ord($this->GroupIsAdmin);
- }
-
- public function Save() {
- $permissions=array();
- foreach ($this->Permissions as $p)
- $permissions[]=$p->PermissionId;
- $this->GroupPermissions=implode(",", $permissions);
-
- parent::Save();
- }
-
- public function HasPermission($permission) {
- // /$arr=print_r($this,true);
- if ($this->GroupIsAdmin==1)
- return true;
-
- foreach ($this->Permissions as $p)
- if ($p->PermissionValue==$permission)
- return true;
-
- return false;
- }
- }
|