filterField = $filterField; $this->managedClass = $managedClass; $this->record = $record; parent::__construct($name, $title, Permission::get_codes(true)); } /** * @param Array $codes */ function setHiddenPermissions($codes) { $this->hiddenPermissions = $codes; } /** * @return Array */ function getHiddenPermissions() { return $this->hiddenPermissions; } function Field() { Requirements::css(SAPPHIRE_DIR . '/css/CheckboxSetField.css'); $source = $this->source; $values = array(); // Get values from the join, if available if(is_object($this->form)) { $record = $this->form->getRecord(); if ($record && $record->hasMethod($this->name)) { $funcName = $this->name; $join = $record->$funcName(); if($join) { foreach($join as $joinItem) { $values[] = $joinItem->Code; } } } } $odd = 0; $options = ''; $inheritedItems = array(); if ($this->record) { if ($this->record->Roles()->Count()) { foreach($this->record->Roles() as $role) { foreach($role->Codes() as $code) { if (!isset($inheritedItems[$code->Code])) $inheritedItems[$code->Code] = array(); $inheritedItems[$code->Code][] = 'from role '.$role->Title; } } } $parentGroups = $this->record->getAllParents(); if ($parentGroups) { foreach ($parentGroups as $parent) { if ($parent->Roles()->Count()) { foreach($parent->Roles() as $role) { if ($role->Codes()) { foreach($role->Codes() as $code) { if (!isset($inheritedItems[$code->Code])) $inheritedItems[$code->Code] = array(); $inheritedItems[$code->Code][] = 'role '.$role->Title.' on group '.$parent->Title; } } } } if ($parent->Permissions()->Count()) { foreach($parent->Permissions() as $permission) { if (!isset($inheritedItems[$permission->Code])) $inheritedItems[$permission->Code] = array(); $inheritedItems[$permission->Code][] = 'group '.$parent->Title; } } } } } if($source) { foreach($source as $categoryName => $permissions) { $options .= "