private function DeleteOldMemberGroups(array $selectedIDs) { $sql = Access::SqlBuilder(); $tblContGrp = ContentMembergroup::Schema()->Table(); $where = $sql->Equals($tblContGrp->Field('Content'), $sql->Value($this->Content()->GetID())); if (count($selectedIDs)) { $inSelected = $sql->InListFromValues($selectedIDs); $where = $where->And_($sql->NotIn($tblContGrp->Field('MemberGroup'), $inSelected)); } ContentMembergroup::Schema()->Delete($where); }
/** * Gets the content's member groups * @param Content $content * @return Membergroup[] Returns the member groups assigned to the content */ static function ContentMembergroups(Content $content) { if (!$content->Exists()) { return array(); } $sql = Access::SqlBuilder(); $tblCmg = ContentMembergroup::Schema()->Table(); $tblMg = Membergroup::Schema()->Table(); $join = $sql->Join($tblCmg); $joinCondition = $sql->Equals($tblCmg->Field('MemberGroup'), $tblMg->Field('ID')); $where = $sql->Equals($tblCmg->Field('Content'), $sql->Value($content->GetID())); $orderBy = $sql->OrderList($sql->OrderAsc($tblMg->Field('Name'))); return Membergroup::Schema()->Fetch(false, $where, $orderBy, null, 0, null, $join, JoinType::Inner(), $joinCondition); }