protected function prepare_sql_items() {
        global $DB;
        if (!preg_match('/\\%ITEMFILTER\\%/', $this->sql)) {
            return;
        }
        $this->init_items_access();
        $unaccessibleitems = array_filter($this->accessibleitems, function($item) {
            return !$item;
        });
        $idx = 0;
        while (preg_match('/^([^\\0]*?)\\%ITEMFILTER\\%([^\\0]*)$/', $this->sql, $matches)) {
            list($sql, $params) = $DB->get_in_or_equal(array_keys($unaccessibleitems),
                    SQL_PARAMS_NAMED, 'ia_'.($idx++).'_', false, 0);
            $this->sql = $matches[1].' '.$sql.' '.$matches[2];
            $this->params += $params;
        }
    }
protected function prepare_sql_items() {
        global $DB;
        if (!preg_match('/\\%ITEMFILTER\\%/', $this->sql)) {
            return;
        }
        $this->init_items_access();
        $unaccessibleitems = array_filter($this->accessibleitems, function($item) {
            return !$item;
        });
        $idx = 0;
        while (preg_match('/^([^\\0]*?)\\%ITEMFILTER\\%([^\\0]*)$/', $this->sql, $matches)) {
            list($sql, $params) = $DB->get_in_or_equal(array_keys($unaccessibleitems),
                    SQL_PARAMS_NAMED, 'ia_'.($idx++).'_', false, 0);
            $this->sql = $matches[1].' '.$sql.' '.$matches[2];
            $this->params += $params;
        }
    }
protected function prepare_sql_items ( ) { global $ DB ; if ( ! preg_match ( '/\\%ITEMFILTER\\%/' , $ this -> sql ) ) { return ; } $ this -> init_items_access ( ) ; $ unaccessibleitems = array_filter ( $ this -> accessibleitems , function ( $ item ) { return ! $ item ; } ) ; $ idx = 0 ; while ( preg_match ( '/^([^\\0]*?)\\%ITEMFILTER\\%([^\\0]*)$/' , $ this -> sql , $ matches ) ) { list ( $ sql , $ params ) = $ DB -> get_in_or_equal ( array_keys ( $ unaccessibleitems ) , SQL_PARAMS_NAMED , 'ia_' . ( $ idx ++ ) . '_' , false , 0 ) ; $ this -> sql = $ matches [ 1 ] . ' ' . $ sql . ' ' . $ matches [ 2 ] ; $ this -> params += $ params ; } }
Substitute %ITEMFILTER% with an expression filtering out items where current user does not have access
Substitute %ITEMFILTER% with an expression filtering out items where current user does not have access