public static function get_notices($context = null)
    {
        // fallback to the CMS as the context - this is required to be consistent with the original behaviour.
        if ($context == null) {
            $context = 'CMS';
        }

         // prepare and filter the possible result
        $now     = DBDatetime::now()->getValue();
        $member  = Member::currentUser();

        $notices = TimedNotice::get()->filter(
            [
                "Context" => $context,
                "StartTime:LessThan" => $now
            ]
        )->filterAny(
            [
                "EndTime:GreaterThan" => $now,
                "EndTime" => null
            ]
        );

         // if there are notices verify if those are allowed for this group
        if ($notices->count()) {
            // turn the DataList into an ArrayList to make it editable.
            $notices = ArrayList::create($notices->toArray());
             foreach ($notices as $notice) {
                if ($notice->CanViewType == 'OnlyTheseUsers') {
                    if ($member && !$member->inGroups($notice->ViewerGroups())) {
                        $notices->remove($notice);
                    }
                }
            }
        }

         return $notices;
    }
public static function get_notices($context = null)
    {
        // fallback to the CMS as the context - this is required to be consistent with the original behaviour.
        if ($context == null) {
            $context = 'CMS';
        }

         // prepare and filter the possible result
        $now     = DBDatetime::now()->getValue();
        $member  = Member::currentUser();

        $notices = TimedNotice::get()->filter(
            [
                "Context" => $context,
                "StartTime:LessThan" => $now
            ]
        )->filterAny(
            [
                "EndTime:GreaterThan" => $now,
                "EndTime" => null
            ]
        );

         // if there are notices verify if those are allowed for this group
        if ($notices->count()) {
            // turn the DataList into an ArrayList to make it editable.
            $notices = ArrayList::create($notices->toArray());
             foreach ($notices as $notice) {
                if ($notice->CanViewType == 'OnlyTheseUsers') {
                    if ($member && !$member->inGroups($notice->ViewerGroups())) {
                        $notices->remove($notice);
                    }
                }
            }
        }

         return $notices;
    }
public static function get_notices ( $ context = null ) { // fallback to the CMS as the context - this is required to be consistent with the original behaviour. if ( $ context == null ) { $ context = 'CMS' ; } // prepare and filter the possible result $ now = DBDatetime :: now ( ) -> getValue ( ) ; $ member = Member :: currentUser ( ) ; $ notices = TimedNotice :: get ( ) -> filter ( [ "Context" => $ context , "StartTime:LessThan" => $ now ] ) -> filterAny ( [ "EndTime:GreaterThan" => $ now , "EndTime" => null ] ) ; // if there are notices verify if those are allowed for this group if ( $ notices -> count ( ) ) { // turn the DataList into an ArrayList to make it editable. $ notices = ArrayList :: create ( $ notices -> toArray ( ) ) ; foreach ( $ notices as $ notice ) { if ( $ notice -> CanViewType == 'OnlyTheseUsers' ) { if ( $ member && ! $ member -> inGroups ( $ notice -> ViewerGroups ( ) ) ) { $ notices -> remove ( $ notice ) ; } } } } return $ notices ; }
Gets any notices relevant to the present time, context and current users

@param string $context (default: CMS)
@return ArrayList
Gets any notices relevant to the present time context and current users