/** * Creates a check list field for groups of a content * @param string $name The field name * @param Content $content The content * @return CheckList Returns the check list */ static function ContentCheckList($name, Content $content) { $field = new CheckList($name); self::AddMembergroupOptions($field); $groupIDs = Membergroup::GetKeyList(self::ContentMembergroups($content)); $field->SetValue($groupIDs); return $field; }
private function SaveMemberGroups() { $selectedIDs = Request::PostArray('MemberGroup'); if ($this->Content()->GetGuestsOnly()) { $selectedIDs = array(); } $exIDs = Membergroup::GetKeyList(MembergroupUtil::ContentMembergroups($this->Content())); $this->DeleteOldMemberGroups($selectedIDs); $this->SaveNewMemberGroups($selectedIDs, $exIDs); }
private function SaveGroups() { $exGroupIDs = Membergroup::GetKeyList(MembergroupUtil::MemberMembergroups($this->member)); $selGroupIDs = Request::PostArray('MemberGroup'); $this->DeleteOldGroups($selGroupIDs); $this->SaveNewGroups($exGroupIDs, $selGroupIDs); }
/** * Checks access to an item by its properties and assigned groups * @param boolean $guestsOnly True if guests only see the item * @param boolean $publish True if item is generally published * @param Date $from The start date of publishing * @param Date $to The end date of publishing * @param Membergroup[] $groups Groups assigned to the item * @return GrantResult */ private function GrantByProperties($guestsOnly, $publish, Date $from = null, Date $to = null, array $groups = array()) { if (!PublishDateUtil::IsPublishedNow($publish, $from, $to)) { return GrantResult::NoAccess(); } if ($this->GetMember() && $guestsOnly) { return GrantResult::NoAccess(); } if (count($groups) == 0) { return GrantResult::Allowed(); } if (!$this->GetMember()) { return GrantResult::LoginRequired(); } $groupIDs = Membergroup::GetKeyList($groups); $memberGroupIDs = Membergroup::GetKeyList($this->Groups()); return count(array_intersect($groupIDs, $memberGroupIDs)) ? GrantResult::Allowed() : GrantResult::NoAccess(); }