/** * Add staff group to the list of groups that this news item will be visible to. * Automatically sets custom staff visibility flag to True. * * @param kyStaffGroup $staff_group Staff group that this news item will be visible to. * @param bool $clear Clear the list before adding. * @return kyNewsItem */ public function addStaffGroup(kyStaffGroup $staff_group, $clear = false) { if ($clear) { $this->staff_groups = array(); $this->staff_group_ids = array(); } if (!in_array($staff_group->getId(), $this->staff_group_ids)) { $this->staff_group_ids[] = $staff_group->getId(); $this->staff_visibility_custom = true; } return $this; }
/** * Returns whether this ticket status can be set by specified staff group. * * @param kyStaffGroup|int $staff_group Staff group or its identifier. * @return bool * @filterBy */ public function isVisibleToStaffGroup($staff_group) { if ($this->staff_visibility_custom === false) { return true; } if ($staff_group instanceof kyStaffGroup) { $staff_group_id = $staff_group->getId(); } else { $staff_group_id = intval($staff_group); } return in_array($staff_group_id, $this->staff_group_ids); }